// Javascipt main functions used for xcessory
<!-- 

function vote(obj)
{
	var i;
	if (obj.getElementById("opt1").checked == true) i = 1;
	if (obj.getElementById("opt2").checked == true) i = 2;
	if (obj.getElementById("opt3").checked == true) i = 3;
	var ur = "poll.php?opt1=" + i + "&opinionID=" + obj.getElementById("opinionID").value;
	popup(ur,300,280,200,200,"ko");
}

function validate(f){
	var props = "toolbar=no,location=no,status=no,scrollbars=no,resizable=no,titlebar=no,menubar=no,left=150,top=100,width=200,height=200";
	w = window.open('poll.php', 'poll', props);
	if (w) {
	w.focus();
	}
	return true;
}

function popup(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=no,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}

function popupimage(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=no,resizable=no,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}


function ValidateAlphaNumeric(myfield,e) 
{ 
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>47) && (keycode<58) ) || ((keycode>=65) && (keycode<=90) )  || (keycode==8) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
} 
    

function ValidateNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>47) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

    
function ValidateAlpha(myfield,e) 
{ 
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>=65) && (keycode<=90) )  || (keycode==8) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
} 

function checkvalid(field,msg)
{
	if (field.value.length < 3)
	{
		alert("Please enter the " + msg + " correctly.");
		field.focus();
		return false;
	}
	return true;
}

function echeck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateCheckoutForm(obj)
{
	var emailID=obj.yemail;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	if ((obj.houseno.value==null)||(obj.houseno.value=="")){
		alert("Please Enter your House No.");
		obj.houseno.focus();
		return false;
	}
	if (!checkvalid(obj.fname,"first name")) return false;
	if (!checkvalid(obj.lname,"last name")) return false;
	if (!checkvalid(obj.street1,"street 1")) return false;
	if (!checkvalid(obj.city,"city")) return false;
	if (!checkvalid(obj.postcode,"delivery post code")) return false;
	if (!checkvalid(obj.telephone,"telephone")) return false;
	if (!checkvalid(obj.country,"country")) return false;
	return true;

}

function validateenqiryform(obj)
{
	var emailID=obj.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	
	if (!checkvalid(obj.fname,"first name")) return false;
	if (!checkvalid(obj.lname,"last name")) return false;
	if (!checkvalid(obj.street1,"street 1")) return false;
	if (!checkvalid(obj.city,"city")) return false;
	if (!checkvalid(obj.postcode,"delivery post code")) return false;
	if (!checkvalid(obj.telephone,"telephone")) return false;
	if (!checkvalid(obj.country,"country")) return false;
	return true;
}


function SearchValidation(obj)
{
	if (!checkvalid(obj.stext,"search term")) return false;
	return true;
}

-->