function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function pop_win(url, win, ht, wd) {
  		popwin = document.open(url,win,"width="+wd+",height="+ht+",toolbar=no,resizable=yes,scrollbars=yes");
 	}


function pop_win2(url, win, ht, wd, lt, tp) {
  		popwin = document.open(url,win,"width="+wd+",height="+ht+",left="+lt+",top="+tp+",toolbar=no,resizable=yes,scrollbars=no");
 	}





function MM_findObj(n, d) { //v4.0
	var p,i,x; 
	if (!d) {
		d=document;
	}
  	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
   		d=parent.frames[n.substring(p+1)].document;
   		n=n.substring(0,p);
  	}
	if (!(x=d[n])&&d.all) {
		x=d.all[n];
	}
	for (i=0; !x&&i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
	for (i=0; !x&&d.layers&&i>d.layers.length; i++) {
		x=MM_findObj(n,d.layers[i].document);
	}
	if (!x && document.getElementById) {
		x=document.getElementById(n);
	}

	return x;
}

function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			if (obj.style) {
				obj=obj.style;
				v=(v=='show')?'visible':(v='hide')?'hidden':v;
			}
    		obj.visibility=v;
		}
	}
}

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);
function printit() {
 if (pr) 
    window.print()
  else if (da && !mac) 
    vbPrintPage()
  else 
    alert('Sorry, your browser does not support this feature. Please print using the menu on your browser.');
}
if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln(' OLECMDID_PRINT = 6');
  writeln(' OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln(' OLECMDEXECOPT_PROMPTUSER = 1');
  writeln(' On Error Resume Next');
  writeln(' WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

function checkAll() {
    if (self.document.forms[0].Name.value == "") {
           alert("\nPlease enter your Name.");
        self.document.forms[0].Name.focus();
        return (false);
    }
    if (self.document.forms[0].Company_Name.value == "") {
           alert("\nPlease enter your Company Name.");
        self.document.forms[0].Company_Name.focus();
        return (false);
    }
    if (self.document.forms[0].Address.value == "") {
           alert("\nPlease enter your Address.");
        self.document.forms[0].Address.focus();
        return (false);
    }
	if (self.document.forms[0].City.value == "") {
           alert("\nPlease enter your City name.");
        self.document.forms[0].City.focus();
        return (false);
    }
    if (self.document.forms[0].State.value == "") {
           alert("\nPlease enter your State name.");
        self.document.forms[0].State.focus();
        return (false);
    }
    if (self.document.forms[0].Zip_Code.value == "") {
           alert("\nPlease enter your Zip Code.");
        self.document.forms[0].Zip_Code.focus();
        return (false);
    }
    if (self.document.forms[0].Country.value == "") {
           alert("\nPlease enter your Country.");
        self.document.forms[0].Country.focus();
        return (false);
    }
    if (self.document.forms[0].Phone.value == "") {
           alert("\nPlease enter your Phone Number.");
        self.document.forms[0].Phone.focus();
        return (false);
    }
    txt=self.document.forms[0].Email.value;
	if (txt == "") {
			alert("Please enter your Email Address");
		self.document.forms[0].Email.focus();
        return (false);
	} else if (txt.indexOf("@")<2){
			alert("This Email Address is not valid."
  +"\nPlease make sure your Email Address contains an '@' sign.");
        self.document.forms[0].Email.focus();
        return (false);
    }
    if (self.document.forms[0].Tax_ID.value == "") {
           alert("\nPlease enter your Wholesale Tax ID Number.");
        self.document.forms[0].Tax_ID.focus();
        return (false);
    }
    return (true);
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
 }}}}
 
function getPass(e){
if(self.document.forms[0].pass.value!="wholepass"){
	alert('The Password you entered is invalid.\n\nPlease re-enter your Password.');
	self.document.forms[0].pass.value="";
	self.document.forms[0].pass.focus();
    return (false);
	}
	if(e==13){self.document.forms[0].action="http://www.continentalbeadsuppliers.com/indexw.htm"}
	else {location.href='indexw.htm'}
    return (true);
}

function getCookie(name) {
var cookieNameLen = name.length;
var cLen = document.cookie.length;
var i = 0;
var cEnd;
var myStringToReturn;
var myStringToReturnLen;
while (i < cLen) {
var j = i + cookieNameLen;
if (document.cookie.substring(i,j) == name) {
cEnd = document.cookie.indexOf(";",j);
if (cEnd == -1) {
cEnd = document.cookie.length;
}
myStringToReturn = unescape(document.cookie.substring(j,cEnd));
myStringToReturnLen = myStringToReturn.length;
myStringToReturn = myStringToReturn.substring(1,myStringToReturnLen+1);
return myStringToReturn;
}
i++;
}
return "";
}

function setVals() {
strCookieVal = getCookie('datapass');
var pasVal = strCookieVal.split("^");
var valCount = pasVal.length
for (var i=1; i<valCount; i++) {
document.forms[0].elements[i].value = pasVal[i];
   }
}

var expDays = 100;
function setCookie(name, val1, val2) {
var exp = new Date();
var cookieTimeToLive = exp.getTime() + (expDays * 24 * 60 * 60 * 1000);
exp.setTime(cookieTimeToLive);
document.cookie = name + "=" + escape(val1) + "^" + escape(val1) + "^" + escape(val2) + "; expires=" + exp.toGMTString();
}

function killErrors(){
alert("Error!!!!!\n\n"+window.onerror);
return true;
}
//window.onerror=killErrors

var orderInst="";
var loc=document.location.href;
var locIndex=loc.indexOf("w.php");
if(loc.indexOf("w2.php")!=-1)locIndex=loc.indexOf("w2.php");
if(loc.indexOf("w3.php")!=-1)locIndex=loc.indexOf("w3.php");
if(loc.indexOf("w4.php")!=-1)locIndex=loc.indexOf("w4.php");

function actSize() {
	if (locIndex==-1) {
		orderInst='<p class="pdbdr"><br>This is just a small sampling of our product line. For product prices or to order products, you will need a <b>Wholesale Account</b> with us. <br><a href="wholesale-bead-account.php"><b>Click here to submit your Wholesale Account Application</b>.</a><br>&nbsp;</p>';
	}
	else {
		orderInst='<p>Please click the "<b>Order NOW!</b>" button at the bottom of this page when you have finished selecting the product items you wish to order from this page.<\p>'
	}
	if (screen.width<=900) {
		document.write(orderInst+'<p>The product images displayed on this page are approximately twice actual size.</p>')
	}
	else if (screen.width>=1200) {
		document.write(orderInst+'<p>The product images displayed on this page are smaller than actual size.</p>')
	}
	else {
		document.write(orderInst+'<p>The product images displayed on this page approximate actual size.</p>')
	}
}

function sayName(){
	if (document.forms[0].Name.value == ""
	&& document.forms[0].Company_Name.value == "") {
		n='<p align=center>You must enter your <b>Name</b> and <b>Company Name</b> before placing an <b>Order</b>.<br><a href="indexw.htm"><b>Click here</b> to enter your <b>Name</b> and <b>Company Name</b><a></p>';
		cn='';
	}
	else if (document.forms[0].Company_Name.value != ""
	&& document.forms[0].Name.value == "") {
		n='<p align=center>You entered your Company Name as: <b><i>'+document.forms[0].Company_Name.value+'</i></b>.<br>You must enter your <b>Name</b> before placing an <b>Order</b>.<br><a href="indexw.htm"><b>Click here</b> to enter your <b>Name</b><a></p>';
		cn='';
	}
	else if (document.forms[0].Name.value != ""
	&& document.forms[0].Company_Name.value == "") {
		n='';
		cn='<p align=center>You entered your Name as: <b>'+document.forms[0].Name.value+'</b>.<br>You must enter your <b>Company Name</b> before placing an <b>Order</b>.<br><a href="indexw.htm"><b>Click here</b> to enter your <b>Company Name</b><a></p>';
	}
	else {
		n="<p align=center>Welcome <b>"+document.forms[0].Name.value+"</b>";
		cn=" of <b><i>"+document.forms[0].Company_Name.value+"</i></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br></p>";
	}
	document.write(n+cn)
}

function reset(form_name) {
	count = document.form_name.elements.length;
	for (i=0; i<count; i++) {
		document.form_name.elements[i].value = '';
	}
}

function setOrderPage(obj, url) {
	val = obj.options[obj.selectedIndex].value;
	if (val != 'none') {
		location.href = url + '?o_id=' + val;
	}
}

function doAction(obj, url, var1, var2_id) {
	val = obj.options[obj.selectedIndex].value;
	if (val != 'none') {
		var1_act = '&' + var1 + '=' + val;
		if (val == 'delete') {
			if (!confirm('Are you sure you want to perform this delete operation?')) {
				return 0;
			}
		}
		
		location.href = url + var1_act + '&' + var2_id;
	}
}

function goTo(obj, url, extra) {
	val = obj.options[obj.selectedIndex].value;
	if (val != 'none') {
		location.href = url + extra + '=' + val;
	}
}

function goTo2(obj, url, extra) {
	val = obj.value;
	location.href = url + extra + '=' + val;
}

function goTo2(obj, url, extra) {
	val = obj.value;
	location.href = url + extra + '=' + val;
}

function goTo3(obj, url, extra) {
	val = obj.value;
	location.href = url + extra + '=' + val;
}