//<!--

//******handing variables through the url*******************************************

var linkfrom = "";
linkfrom = location.search.substr(1).split("?");//sets variable as whatever follows question mark in the url
function DisplayPage(){
	if (linkfrom == "") {
		document.getElementById("loading").style.display ="none";
		DisplayProduct("splash");
	}
	else {
		document.getElementById("loading").style.display ="none";
		DisplayProduct(linkfrom);
	}
}


//******************SUBMENU FUNCTION************************************************
var submenu="";

function DisplaySubmenu(){
	if (submenu==""){}
	else if (submenu=="newproducts"){
		for (z in ProductArrays[0]){
			var tr=document.getElementById("NavTable").insertRow(1);
			var td=tr.insertCell(0);
			if (z==0){product=ProductsJoin[0][0];};
			if (z==1){product=ProductsJoin[0][1];};
			if (z==2){product=ProductsJoin[0][2];};
			if (z==3){product=ProductsJoin[0][3];};
			if (z==4){product=ProductsJoin[0][4];};
			if (z==5){product=ProductsJoin[0][5];};
			td.innerHTML="<a class='greenlink' href='"
				+"newproducts.shtml?"+product
				+"'>&nbsp;&nbsp;&nbsp;"
				+ProductArrays[0][z]+"</a>";
				
			//this is the first way I did it: (and add quotes to product="productsjoin[][]"...like memory dock below)
			//td.innerHTML="<a class='greenlink' href='#' onclick='"
			//	+"DisplayProduct("+product+")"
			//	+"'>&nbsp;&nbsp;&nbsp;"
			//	+ProductArrays[0][z]+"</a>";
		}
	}
	else if (submenu=="memorydock"){
		for (z in ProductArrays[1]){
			var tr=document.getElementById("NavTable").insertRow(2);
			var td=tr.insertCell(0);
			if (z==0){product="ProductsJoin[1][0]";};
			if (z==1){product="ProductsJoin[1][1]";};
			td.innerHTML="<a class='greenlink' href='#' onclick='"
				+"DisplayProduct("+product+")"
				+"'>&nbsp;&nbsp;&nbsp;"
				+ProductArrays[1][z]+"</a>";
		}
	}
	
	//innerHTML:<a class='greenlink' href='#' 
	//				onclick='DisplayProduct(ProductsJoin[2][z])'>
	//				&nbsp;&nbsp;&nbsp;ProductArrays[2][z]</a>
	
	
	else if (submenu=="classicproducts"){
		for (z in ProductArrays[2]){
			var tr=document.getElementById("NavTable").insertRow(3);
			var td=tr.insertCell(0);
			if (z==0){product=ProductsJoin[2][0];};
			if (z==1){product=ProductsJoin[2][1];};
			if (z==2){product=ProductsJoin[2][2];};
			td.innerHTML="<a class='greenlink' href='"
				+"classicproducts.shtml?"+product
				+"'>&nbsp;&nbsp;&nbsp;"
				+ProductArrays[2][z]+"</a>";
				
			//td.innerHTML="<a class='greenlink' href='#' onclick='"
			//	+"DisplayProduct("+product+")"
			//	+"'>&nbsp;&nbsp;&nbsp;"
			//	+ProductArrays[2][z]+"</a>";
			
		}
	}
	
	
	
}






//******************RESIZE FUNCTION************************************************	
	
function Resize(category, subcategory) {
if (category=="about") {
	if (subcategory=="none") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="president") {document.getElementById("main").style.height="750px"}
	else if (subcategory=="aboutus") {document.getElementById("main").style.height="1150px"}
	else if (subcategory=="team") {document.getElementById("main").style.height="443px"}
	}
else if (category=="products") {
	if (subcategory=="none") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="splash") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="crop-a-dile") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="cropadile") {document.getElementById("main").style.height="2075px"}
	else if (subcategory=="newcrop-a-dile") {document.getElementById("main").style.height="510px"}
	else if (subcategory=="rawgoods") {document.getElementById("main").style.height="875px"}
	else if (subcategory=="classicleather") {document.getElementById("main").style.height="600px"}
	else if (subcategory=="metallicpaper") {document.getElementById("main").style.height="1400px"}
	else if (subcategory=="metalembellishments") {document.getElementById("main").style.height="1400px"}
	else if (subcategory=="kitproducts") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="memorydocksystem") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="cargocollection") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="tabdispenser") {document.getElementById("main").style.height="1100px"}
	else if (subcategory=="linenalbums") {document.getElementById("main").style.height="600px"}
	else if (subcategory=="pageprotectors") {document.getElementById("main").style.height="600px"}
	}
else if (category=="ideas") {
	if (subcategory=="none") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="productideas") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="kitideas") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="guestdesigner") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="beguestdesigner") {document.getElementById("main").style.height="443px"}
	else if (subcategory=="contest") {document.getElementById("main").style.height="443px"}
	}
else if (category=="customwork") {document.getElementById("main").style.height="800px"}
else if (category=="contact") {document.getElementById("main").style.height="550px"}
else if (category=="purchase") {document.getElementById("main").style.height="443px"}
else if (category=="faqs") {document.getElementById("main").style.height="1200px"}
else {}
}


//******************PRODUCT FUNCTIONS************************************************


//be sure the title would be okay as a an html ID when the spaces are taken out
//newest additions go at the end - they will be displayed at the beginning
var NewProductsTitles=new Array();
NewProductsTitles[0]="crop-a-dile";
NewProductsTitles[1]="new crop-a-dile";
NewProductsTitles[2]="raw goods";
NewProductsTitles[3]="metal embellishments";
NewProductsTitles[4]="metallic paper";
NewProductsTitles[5]="classic leather";

var MemoryDockTitles=new Array();
MemoryDockTitles[0]="cargo collection";
MemoryDockTitles[1]="memory dock system";

var ClassicProductsTitles=new Array();
ClassicProductsTitles[0]="page protectors";
ClassicProductsTitles[1]="linen albums";
ClassicProductsTitles[2]="tab dispenser";

var ProductArrays=new Array();
ProductArrays[0]=NewProductsTitles;
ProductArrays[1]=MemoryDockTitles;
ProductArrays[2]=ClassicProductsTitles;


var ProductsSplit=new Array();
for (x in ProductArrays){ProductsSplit[x]=new Array();}

for (x in ProductArrays){
	for (y in ProductArrays[x]){
		ProductsSplit[x][y]=ProductArrays[x][y].split(" ");
	}
}

var ProductsJoin=new Array();
for (x in ProductArrays){ProductsJoin[x]=new Array();}

for (x in ProductsSplit) {
	for (y in ProductsSplit[x]){
		ProductsJoin[x][y]=ProductsSplit[x][y].join("");
	}
}




var CurrentContents = "";//keeps track of which div is visible
function ClearContents(x){
	document.getElementById(x).style.display ="none";
}//This function hides whichever content div is currently visible



function DisplayProduct(x){
	ClearContents(CurrentContents);
	Resize("products",x);
	document.getElementById(x).style.display="inline";
	CurrentContents=x;
}


//******************FORM VALIDATION************************************************



function validate_form(thisform) {

	with (thisform) {
		if (validate_required(name,"Please enter your name.")==false)
		  {name.focus();return false}
	}
	with (thisform) {
		if (validate_required(comment,"Please enter a comment.")==false)
		  {comment.focus();return false}
	}
	with (thisform) {
		if (validate_email(email,"Not a valid e-mail address.")==false)
		  {email.focus();return false}
	}
	//with (thisform) {
		//if (validate_captcha(strCAPTCHA,"Did not verify. Please identify image characters again.")==false)
		//{strCAPTCHA.focus();return false}
	//}
}

//function validate_captcha(field,alerttxt) {
//	with (field) {
//			var ImageAnswer;
//			ImageAnswer = <%=Session("CAPTCHA")%>;

//		if (value==null||value=="")
//		  {alert(alerttxt);return false}
//		else {return true}
//	}
//}

function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="")
		  {alert(alerttxt);return false}
		else {return true}
	}
}

function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		  {alert(alerttxt);return false}
		else {return true}
	}
}


//-->
