	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var loaded = false;
	var motion = false;
	
	var Preload = {
		onComplete:{},
		imgComplete: 0,
		loadingImage:'loadingImage',
		arg: 0,
		checkOnLoad: function(){
			Preload.imgComplete++;
			if(Preload.imgComplete == Preload.arg){
				if(motion){
					if(Preload.loadingImage!='') Element.hide(Preload.loadingImage);
					Preload.onComplete();
				} else loaded = true;
			}
		},
		load: function(){
			motion = loaded = false;
			Preload.imgComplete = 0;
			Preload.arg = arguments.length;
			var img = new Array();
			for(i=0; i<Preload.arg; i++){
				img[i] = new Image();
				img[i].src = arguments[i];
				if(img[i].complete) Preload.checkOnLoad();
				else img[i].onload = function(){ Preload.checkOnLoad(); }
			}
		}
	}
	
	function checkLoadImage(){
		if(loaded) Preload.onComplete();
		else {
			motion = true;
			if(Preload.loadingImage!='') Element.show(Preload.loadingImage);
		}
	}
	
	
	function getPageSize(){	
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
	
	function showPopupWindow(){
		var whichone = arguments[0];
		var arg = (arguments[1]) ? arguments[1] : '';
		var ps = getPageSize();
		var mytop = window.screenTop != undefined ? window.screenTop : window.screenY;
		var myleft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
		mytop += (ps[3] - 500) /2;
		myleft += (ps[2] - 450 ) /2;
		window.open('/popup/' + whichone + '.htm'+arg, whichone, 'width=450,height=500,left='+myleft+',top='+mytop);
	}
	
	function CreateBookmark(){
		var url = "http://www.askomi.com/";
		var title = document.title;
		if(isIE) window.external.AddFavorite(url, title);
		else	alert('Press Ctrl + D to bookmark the page.');
	}
	
	function changeCurrency(code){
		if(currency_code == code) return;
		document.getElementById('GBP').className = "";
		document.getElementById('EUR').className = "";
		document.getElementById('USD').className = "";
		document.getElementById(code).className = document.getElementById(code).className + "on";
		var resource = document.getElementsByTagName("span");
		for(i=0;i<resource.length; i++){
			if(resource[i].getAttribute("rel")=="price"){
				resource[i].innerHTML = getMoney(parseFloat(resource[i].firstChild.nodeValue.substr(1).replace(/,/gi, '')), code);
			}
		}
		sendGET('/phpengine/mycart.php?currency='+code);
		currency_code = code;
	}
	
	function getMoney(){
		var money = arguments[0];
		var mycode;
		var result;
		if(arguments.length==1){
			result = money*currency[currency_code].exchange;
			mycode = currency_code;
		} else {
			mycode = arguments[1];
			result = money/currency[currency_code].exchange*currency[mycode].exchange;
		}
		return currency[mycode].symbol+setNumberFormat(result.toFixed(2));
	}
	
	function setNumberFormat(num){
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = num.toString().split('.');
		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} while (rxSplit.test(arrNumber[0]));
		if (arrNumber.length > 1) return arrNumber.join('');
		else return arrNumber[0].split('.')[0];
	}
	
	function checkSearchForm(){
		var form = document.forms.searchForm;
		if(form.keyword.value == "" || form.keyword.value=="search"){ alert("Please enter search keyword."); form.keyword.focus(); return false; }
		return true;
	}