// JavaScript Document
function openWind(pid) {
	bigWindow = window.open('big_image.php?PID='+ pid +'&POS=P','test','height=535,width=535,top=0,left=0,toolbar=no,titlebar=no,location=no,scrollbars=1')
	bigWindow.focus();
}
////////////////////////////
var xmlHttp
function showpage(ctlName,page){
	var xmlHttp = GetXmlHttpObject();
	var url = page+"&sid="+Math.random();
	if (!xmlHttp){
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
//			if(xmlHttp.responseText=='&nbsp;'){
				document.getElementById(ctlName).innerHTML=xmlHttp.responseText;
//			}
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function GetXmlHttpObject(){ 
var objXMLHttp=null;

     if (window.XMLHttpRequest){
          objXMLHttp=new XMLHttpRequest();
     }else if (window.ActiveXObject){
          objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     return objXMLHttp;
}
/////////////////////
function test(obj,msg){
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (regex.test(obj.value)){
		return true;
	}else{
		alert(msg);
		obj.focus();
		return false;
	}
}
function checkempty(obj,msg){
	if(obj.value==''){
		alert(msg);
		obj.focus()
		return false;
	}
	return true;
}
function confirmpass(obj,obj1,msg){
	if(obj1.value!=obj.value){
		alert(msg);
		obj1.focus();
		obj1.select();
		return false;
	}
	return true;
}
function chkStock(obj,obj1,msg){
	if(obj1.value>obj.value){
		alert(msg);
		obj1.focus();
		obj1.select();
		return false;
	}
	return true;
}
function checkdate(obj,msg){
	if(obj.value==''){
		alert(msg);
		document.all.trigger.focus();
		return false;
	}
	return true;
}
function checkZero(obj,msg){
	if(obj.value==0){
		alert(msg);
		return false;
	}
	return true;
}
function doSubmit(val){
	document.frmActions.act.value=val;
	document.frmActions.submit();
}
/////////////////////
function checkAll(theForm, cName, allNo_stat){
	var n=theForm.elements.length;
	for (var i=0;i<n;i++){
		if (theForm.elements[i].className.indexOf(cName) !=-1){
			if (allNo_stat.checked) {
				theForm.elements[i].checked = true;
			}else{
				theForm.elements[i].checked = false;
			}
		}
	}
}
function SelectedEmails(){
	var varEmails = document.frmCatalogue.Chk.length;
	var varEmailsSelect = 0;
	if(varEmails){
		for(i = 0; i <= varEmails-1; i++){
			if(document.frmCatalogue.Chk[i].checked){
				varEmailsSelect++;
			}
		}
	}
	if(!varEmails){
		if(document.frmCatalogue.Chk.checked){
				varEmailsSelect++;
		}
	}
	return(varEmailsSelect);
}
function clearImage(){
//    r = window.clipboardData.clearData("Image")
}
ci = setInterval("clearImage()", 10);
/////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
/////////////////////
function CheckUserLogin(){
	if(checkempty(document.frmUserLogin.txtUName,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmUserLogin.txtPass,"Information: Enter Password")==false) return false;
	return true;
}
function CheckUserLogin1(){
	if(checkempty(document.frmUserLogin1.txtUName,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmUserLogin1.txtPass,"Information: Enter Password")==false) return false;
	return true;
}
function CheckSearch(){
	if(checkempty(document.frmSearch.key,"Information: Enter Search Keywords")==false) return false;
	return true;
}
function chkQty(vfrm){
	if(checkempty(document.frmCart.qty,"Information: Enter Quantity")==false) return false;
	return true;
}
function chkNlFrm(){
	if(test(document.frmNl.email,"Information: Enter Valid Email Address")==false) return false;
	return true;
}
function chkfrmFP(){
	if(test(document.frmFP.email,"Information: Enter Valid Email Address")==false) return false;
	return true;
}
function CheckForgotFrm(){
	if(checkempty(document.frmFPass.txtUN,"Information: Enter Username")==false) return false;
	if(checkempty(document.frmFPass.SHint,"Information: Select Secret Question")==false) return false;
	if(checkempty(document.frmFPass.txtHintAns,"Information: Enter Secret Answer")==false) return false;
	return true;
}
function chknUser(){
	if(checkempty(document.frmNewUser.txtcname,"Information: Enter Company Name")==false) return false;
	if(checkempty(document.frmNewUser.txtcperson,"Information: Enter Contact Person Name")==false) return false;
	if(test(document.frmNewUser.txtmail,"Information: Enter Email")==false) return false;
	return true;
}
function CheckSendInquiry(){
	if(checkempty(document.frmSendInquiry.txtCompName,"Information: Enter Company Name")==false) return false;
	if(checkempty(document.frmSendInquiry.txtCPerson,"Information: Enter Contact Person Name")==false) return false;
	if(checkempty(document.frmSendInquiry.txtPhone,"Information: Enter Phone")==false) return false;
	if(test(document.frmSendInquiry.txtEmail,"Information: Enter Email")==false) return false;
	if(checkempty(document.frmSendInquiry.txtAddress,"Information: Enter Address")==false) return false;
	if(checkempty(document.frmSendInquiry.txtCity,"Information: Enter City")==false) return false;
	if(checkempty(document.frmSendInquiry.txtZCode,"Information: Enter ZipCode")==false) return false;
	return true;
}
function chkfeedfrm(){
	if(checkempty(document.frmFeed.fullname,"Information: Enter Your Full Name")==false) return false;
	if(checkempty(document.frmFeed.phone,"Information: Enter Your Phone Number")==false) return false;
	if(test(document.frmFeed.email,"Information: Enter Your Email")==false) return false;
	if(checkempty(document.frmFeed.comments,"Information: Enter Comments")==false) return false;
	return true;
}
function chkfeedbfrm(){
	if(checkempty(document.frmFeed.fullname,"Information: Enter Your Name")==false) return false;
	if(checkempty(document.frmFeed.phone,"Information: Enter Your Phone Number")==false) return false;
	if(test(document.frmFeed.email,"Information: Enter Your Valid Email")==false) return false;
	if(checkempty(document.frmFeed.comments,"Information: Enter Your Message")==false) return false;
}
function chkfrmRegister(){
	if(checkempty(document.frmRegister.UserName,"Information: Please Enter Username")==false) return false;
	if(checkempty(document.frmRegister.Password,"Information: Please Enter Password")==false) return false;
	if(checkempty(document.frmRegister.CPassword,"Information: Please Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmRegister.Password,document.frmRegister.CPassword,"Information: Password and Confirm Password does not match")==false) return false;
	if(checkempty(document.frmRegister.firstname,"Information: Please Enter First Name")==false) return false;
	if(checkempty(document.frmRegister.lastname,"Information: Please Enter Last Name")==false) return false;
	if(checkempty(document.frmRegister.Phone,"Information: Please Enter Phone Number")==false) return false;
	if(test(document.frmRegister.Email,"Information: Please Enter Valid Email")==false) return false;
	if(checkempty(document.frmRegister.Address,"Information: Please Enter Address")==false) return false;
	if(checkempty(document.frmRegister.City,"Information: Please Enter City")==false) return false;
	if(checkempty(document.frmRegister.ustate,"Information: Please Enter State")==false) return false;
	if(checkempty(document.frmRegister.zcode,"Information: Please Enter Zip/Postal Code")==false) return false;
	if(checkempty(document.frmRegister.Country,"Information: Please Enter Country")==false) return false;
	return true;
}
function chkfrmUpdateP(){
	if(checkempty(document.frmUpdateP.Password,"Information: Please Enter Password")==false) return false;
	if(checkempty(document.frmUpdateP.CPassword,"Information: Please Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmUpdateP.Password,document.frmUpdateP.CPassword,"Information: Password and Confirm Password does not match")==false) return false;
	if(checkempty(document.frmUpdateP.firstname,"Information: Please Enter First Name")==false) return false;
	if(checkempty(document.frmUpdateP.lastname,"Information: Please Enter Last Name")==false) return false;
	if(checkempty(document.frmUpdateP.Phone,"Information: Please Enter Phone Number")==false) return false;
	if(test(document.frmUpdateP.Email,"Information: Please Enter Valid Email")==false) return false;
	if(checkempty(document.frmUpdateP.Address,"Information: Please Enter Address")==false) return false;
	if(checkempty(document.frmUpdateP.City,"Information: Please Enter City")==false) return false;
	if(checkempty(document.frmUpdateP.ustate,"Information: Please Enter State")==false) return false;
	if(checkempty(document.frmUpdateP.zcode,"Information: Please Enter Zip/Postal Code")==false) return false;
	if(checkempty(document.frmUpdateP.Country,"Information: Please Enter Country")==false) return false;
	return true;
}
function chkuFrmCP(){
	if(checkempty(document.frmUpduPass.oPass,"Information: Enter Your Old Password")==false) return false;
	if(checkempty(document.frmUpduPass.nPass,"Information: Enter Your New Password")==false) return false;
	if(checkempty(document.frmUpduPass.cnPass,"Information: Enter Confirm Password")==false) return false;
	if(confirmpass(document.frmUpduPass.nPass,document.frmUpduPass.cnPass,"Information: Password and Confirm Password does not match")==false) return false;
	return true;
}
function CheckSendCatalogue(){
	varSEmails = SelectedEmails()
	if(varSEmails <= 0){
		alert("Select Category")	
		return false;		
	}
	if(checkempty(document.frmCatalogue.txtcname,"Information: Please type company name")==false) return false;
	if(checkempty(document.frmCatalogue.txtcperson,"Information: Please type contact person")==false) return false;
	if(test(document.frmCatalogue.txtmail,"Information: Please type valid email")==false) return false;
	if(checkempty(document.frmCatalogue.txtaddress,"Information: Please type address")==false) return false;
	if(checkempty(document.frmCatalogue.txttel,"Information: Please type Phone no.")==false) return false;
	return true;
}
function chkAddress(){
	if(checkempty(document.frmShip.txtFName,"Information: Enter First Name")==false) return false;
	if(checkempty(document.frmShip.txtLName,"Information: Enter Last Name")==false) return false;
	if(checkempty(document.frmShip.txtAddress1,"Information: Enter Address")==false) return false;
	if(checkempty(document.frmShip.txtCity,"Information: Enter City")==false) return false;
	if(checkempty(document.frmShip.cmbState,"Information: Enter State")==false) return false;
	if(checkempty(document.frmShip.cmbCountry,"Information: Select Country")==false) return false;
	if(checkempty(document.frmShip.txtPCode,"Information: Enter Zip/Postal Code")==false) return false;
	if(checkempty(document.frmShip.txtPhone,"Information: Enter Phone Number")==false) return false;
	if(test(document.frmShip.txtEmail,"Information: Enter Valid Email")==false) return false;
	return true;
}//////////////////////////////

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
//			for (var i=0; i<ar.length; i++){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
