
//********************************************************* Detect Browser

var browser

if (document.layers) {
	browser = 'NS4';	
}
else if (document.getElementById && !document.all) {
	browser = 'NS6';	
}
else if (document.all && navigator.userAgent.indexOf("Opera")>-1){
	browser = 'Opera';	
}
else if (document.all) {
	browser = 'IE';	
}
else {
	browser = 'Other';	
}


//********************************************************* Pop-Up Window Function
function popUp(page,w,h,content){
   var thisWin;
   wWidth = window.screen.width;
   wHeight = window.screen.height;
   pWidth = w;
   pHeight = h;
   xPos =  parseInt((wWidth-pWidth)/2);
   yPos =  parseInt((wHeight-pHeight)/2);
   winProp = "top="+yPos+",left="+xPos+",width="+pWidth+",height="+pHeight+",scrollbar=no,resizable=yes"; 
   
   if(page.length > 0){	
		thisWin = window.open(page,"newWin",winProp);
		thisWin.focus();
   }	
   else if (content.length > 0) {
		thisWin = window.open("","newWin",winProp);
		thisWin.document.open();		
		thisWin.document.write(content);
		thisWin.document.close();
		thisWin.focus();	
   }
}


//************************************************ Product's Pictures Pop-Up Window Function
function popUpPicture(lang,size,large,cat,id,w,h){
	var thisWin;
	wWidth = window.screen.width;
	wHeight = window.screen.height;
	pWidth = w;
	pHeight = h;
	xPos =  parseInt((wWidth-pWidth)/2);
	yPos =  parseInt((wHeight-pHeight)/2);
	
	winProp = "top="+yPos+",left="+xPos+",width="+pWidth+",height="+pHeight+",scrollbar=no,resizable=yes"; 
	page = "../shop/PopUpPicture.asp?lang="+lang+"&size="+size+"&large="+large+"&cat="+cat+"&id="+id;
	
	thisWin = window.open(page,"newWin",winProp);
	thisWin.focus();	
}



//********************************************************* Continue Shopping Function
function continueShopping(backPage,page){
	if(browser != 'NS4' && browser!= 'NS6'){
		window.location.href=backPage;
	}
	else{
//		window.location.href = page;
		document.location.href=page;
	}
}


//********************************************************* SUBMIT BASKET UPDATE Function
function autoUpdate(){
	if(browser=='IE'||browser=='NS6'){
		window.document.theForm.update.click();
	}
}


//********************************************* CHECK QUICK SEARCH FORM Function
function checkSearchForm(alertMsg){
	if(document.searchForm.keyword.value.length<=1) {
		alert(alertMsg);
		document.searchForm.keyword.focus();
		return false;
	}	
}


//********************************************* CHECK ADVANCED SEARCH FORM Function
function checkAdvancedSearchForm(msgFrom,msgTo){
	var lowprice;
	var highprice;
	var pass1;
	var pass2;
	var send;
	
	pass1 = true;
	pass2 = true;	
	send = true;
	lowprice = document.advancedSearchForm.pl.value;
	highprice = document.advancedSearchForm.ph.value;
		
	if(lowprice.length>0){
		for(i=0;i<lowprice.length;i++){
			if(isNaN(lowprice.charAt(i))){
				send = false;
				pass1 = false				
			}
		}
		if(!pass1){
			alert(msgFrom);
			document.advancedSearchForm.pl.focus();	
		}		
	}
	
	if(highprice.length>0){
		for(i=0;i<highprice.length;i++){
			if(isNaN(highprice.charAt(i))){
				send = false;
				pass2 = false;				
			}
		}
		if(!pass2){
			alert(msgTo);
			document.advancedSearchForm.ph.focus();			
		}
	}
		
	return send;   
}   





//********************************************************* CHECK EMAIL Function
function checkEmail(thisEmail,msg1,msg2){
	var strEmail = thisEmail;
	
	if(strEmail<=1){
		alert(msg1);
		return false;
	}
	
	if(strEmail.indexOf("@")<1 || strEmail.indexOf(".")<0){
		alert(msg2);
		return false;
	}
	else {
		return true;
	}
}