// Popup Window Starts Here

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=250,height=450,screenX=150,screenY=150,top=150,left=150')
}

// Popup Window Ends Here

// Menu Starts Here

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

// Menu Ends Here

// Form Validation Starts Here

function checkform4()
{
if (checkempty4(document.loginfrm.fname,":.. Please enter your first name.:")==false) return false;
if (checkempty4(document.loginfrm.lname,":.. Please enter your last name.:")==false) return false;
if (checkempty4(document.loginfrm.company,":.. Please enter your company name.:")==false) return false;
if (checkempty4(document.loginfrm.address,":.. Please enter your billing address.:")==false) return false;
if (checkempty4(document.loginfrm.city,":.. Please enter your city name.:")==false) return false;
if (checkempty4(document.loginfrm.zip,":.. Please enter your zipcode.:")==false) return false;
if (checkempty4(document.loginfrm.pstate,":.. Please enter your state.:")==false) return false;
if (checkempty4(document.loginfrm.country,":.. Please enter your country.:")==false) return false;
if (checkempty4(document.loginfrm.phone,":.. Please enter your phone.:")==false) return false;
if (test4(document.loginfrm.email,":.. Please enter your valid billing email address.:")==false) return false;
if (checkempty4(document.loginfrm.s_fname,":.. Please enter your shipping first name.:")==false) return false;
if (checkempty4(document.loginfrm.s_lname,":.. Please enter your shipping last name.:")==false) return false;
if (checkempty4(document.loginfrm.s_company,":.. Please enter your shipping company name.:")==false) return false;
if (checkempty4(document.loginfrm.s_address,":.. Please enter your shipping address.:")==false) return false;
if (checkempty4(document.loginfrm.s_city,":.. Please enter your shipping city.:")==false) return false;
if (checkempty4(document.loginfrm.s_zip,":.. Please enter your shipping zipcode.:")==false) return false;
if (checkempty4(document.loginfrm.s_pstate,":.. Please enter your shipping state.:")==false) return false;
if (checkempty4(document.loginfrm.s_country,":.. Please enter your shipping country.:")==false) return false;
if (checkempty4(document.loginfrm.s_phone,":.. Please enter your shipping phone.:")==false) return false;
if (test4(document.loginfrm.s_email,":.. Please enter your valid shipping email address.:")==false) return false;
if (checkempty4(document.loginfrm.userid,":.. Please enter your desired username.:")==false) return false;
if (checkempty4(document.loginfrm.userpass,":.. Please enter your desired password.:")==false) return false;


function checkempty4(obj,msg)
{
 if(obj.value=="")
 {
  alert(msg);
  obj.focus();
  return false;
 }
}
function test4(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;
		  }
		}
return true;
}

// Form Validation Ends Here

// Function which checks if user has selected a value different than default

function SelectDifferent() {

var inc = 1
while (document.getElementById("opt"+inc)){
if (checkdefault(document.getElementById("opt"+inc),"Please select required size/color/weight")==false){
return false
break
}
inc++
}


// Create Account Form Validation Starts Here

function checkform3()
{
if (checkempty3(document.frm_inq.fname,":.. Please enter your Name.:")==false) return false;
if (checkempty3(document.frm_inq.zip,":.. Please enter Zip Code.:")==false) return false;
if (checkempty3(document.frm_inq.phone,":.. Please enter your Phone No.:")==false) return false;
if (test(document.frm_inq.email,":.. Please enter your Valid E-mail Address.:")==false) return false;

function checkempty3(obj,msg)
{
 if(obj.value=="")
 {
  alert(msg);
  obj.focus();
  return false;
 }
}
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;
		  }
		}
return true;
}


function checkdefault(obj,msg)
{
 if(obj.value=="default")
 {
  alert(msg);
  obj.focus();
  return false;
 }
}


return true;
}

// Function which checks if user has selected a value different than default

// Function to change class on mouse over for form buttons

function hov(loc,cls) {
	  if(loc.className)
	    loc.className=cls;
	}

function goback() {
				history.go(-1);
			}
