function showPointer(sState)
{
	document.body.style.cursor = sState;
}

function swapNavGraphic(imgName,actionState)
{
		eval("document." + imgName + ".src = '/images/" + imgName + "_" + actionState + ".jpg';");
}

function validateLogin()
{
	if(document.forms[0].txtUSERNAME.value == "" || document.forms[0].txtPASSWORD.value == "")
	{
		alert("You seem to be missing a username or password, please make sure both are filled in and click \"log in\"");
	}
	else
	{
		document.forms[0].submit();	
	}
}

// GO Admin Function Page
function goAdmin(pageLocation)
{
	//top.frames["mainFrame"].document.baseImage.src
	eval("top.frames['bottomFrame'].location.href=\"" + pageLocation + "\";")
}

// Launching Pages from the Admin Menu Screens
function submitAdminAction(pageName,fieldName,actionName)
{
	if(actionName == "modify")
	{
		eval("window.location.href=\"admin_" + pageName + "_" + actionName + ".asp?id=\" + document.forms[0]." + fieldName + ".options[document.forms[0]." + fieldName + ".selectedIndex].value + \"\"");
	}
	else if(actionName == "launch")
	{
		eval("window.open('admin_" + pageName + "_" + actionName + ".asp',null,'height=300,width=400,menu=no');")
	}
	else
	{
		eval("window.open('admin_" + pageName + "_" + actionName + ".asp?id=' + document.forms[0]." + fieldName + ".options[document.forms[0]." + fieldName + ".selectedIndex].value,null,'height=300,width=400,menu=no');")
	}
}

// Global Form Functions
function cancelAdmin()
{
	window.history.go(-1);
}

// Admin Form Functions
function validateUser()
{
	if (document.forms[0].txtUSER_FNAME.value == "" || document.forms[0].txtUSER_LNAME.value == "")
	{
		alert("You are about to save an User without a Firstname/Lastname, these fields are required. Please complete form and click Save Update again.");
		return false;
	}
	else
	{
		if (document.forms[0].txtUSERNAME.value == "" && document.forms[0].txtPASSWORD.value != "")
			{
				alert("You have a Password but not a Username, you can either remove the password and submit or add a Username. Note: Username/Password are not required except for administrators.")
				return false;
			}
		else if (document.forms[0].txtUSERNAME.value != "" && document.forms[0].txtPASSWORD.value == "")
			{
				alert("You have a Username but not a Password, you can either remove the Username and submit or add a Password. Note: Username/Password are not required except for administrators.")
				return false;
			}
		else
			{
				return;
			}
	}
}

function ponumberSwitch(urlValue)
{
	if(document.forms[0].cmbREQUEST_TYPE.options[document.forms[0].cmbREQUEST_TYPE.selectedIndex].value == 0)
	{
		document.forms[0].txtPONUMBER.value = "N/A";
		document.forms[0].txtPONUMBER.disabled = true;
	}
	else if(document.forms[0].cmbREQUEST_TYPE.options[document.forms[0].cmbREQUEST_TYPE.selectedIndex].value == 1)
	{
		document.forms[0].txtPONUMBER.value = "";
		document.forms[0].txtPONUMBER.disabled = false;
	}
	else
	{
		window.location.href = urlValue;
	}
}

function validateRequest()
{
	if( document.forms[0].txtCONTACT_INFO.value == "")
	{
		alert("You are missing 1 or more required fields, required fields have an * by them");
		return false;
	}
	else
	{
		return true;
	}
}

function validateCustomer()
{
	if(document.forms[0].cmbACTIVE_FLAG.options[document.forms[0].cmbACTIVE_FLAG.selectedIndex].value == "1" && (document.forms[0].txtUSERNAME.value == "" || document.forms[0].txtPASSWORD.value == "" || document.forms[0].txtPASSWORD2.value == "" ||document.forms[0].txtSUBMISSION_EMAIL.value == ""))
	{	
		alert("You cannot activate a customer without a Username, Password and Submission Email Address.");
		return false;
	}
	else
	{
		if(document.forms[0].txtPASSWORD.value != document.forms[0].txtPASSWORD2.value)
		{	
			alert("The passwords do not match, please correct this and try again.");
			return false;
		}
		else
		{
			return true;
		}
	}
}

function callUpload(uploadFieldName,formNumber)
{
	if(formNumber != 1 && formNumber != 2)
	{
		eval("window.open(\"../../_inc/_upload/upload_file.aspx?formnumber=0&fieldname=" + uploadFieldName + "\",\"\",\"height=250,width=350,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0\")")
	}
	else if(formNumber == 1)
	{
		eval("window.open(\"../../_inc/_upload/upload_file.aspx?formnumber=1&fieldname=" + uploadFieldName + "\",\"\",\"height=250,width=350,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0\")")
	
	}
	else if(formNumber == 2)
	{
		eval("window.open(\"../../_inc/_upload/upload_file.aspx?formnumber=2&fieldname=" + uploadFieldName + "\",\"\",\"height=250,width=350,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0\")")
	
	}
}

function navigationSwap(objImage,state,imgType)
{
		if(state=='_off')
		{
			document.body.style.cursor = 'default';
		}
		else
		{
			document.body.style.cursor = 'hand';			
		}
		if(imgType=='png')
		{
			objImage.src = "images/" + objImage.name + state + ".png";
		}
		else if(imgType=='jpg')
		{
			objImage.src = "images/" + objImage.name + state + ".jpg";
		}
}

function popupImage900x600(imageName)
{
	eval("window.open('imagepopup900x600.asp?imgname=" + imageName + "',null,'height=600,width=900,location=no,scrollbars=no,menu=no,resizable=no');");
}

function popupImage400x600(imageName)
{
	eval("window.open('imagepopup400x600.asp?imgname=" + imageName + "',null,'height=600,width=400,location=no,scrollbars=no,menu=no,resizable=no');")
}

function popupImage700x300(pageName)
{
	eval("window.open('" + pageName + "',null,'height=300,width=700,scrollbars=no,location=no,menu=no,resizable=no');");
}

function changePrintQTY()
{
	if(document.forms[0].cmbQTY.options[document.forms[0].cmbQTY.selectedIndex].value != "Other")
	{
		document.forms[0].txtQTY_OTHER.disabled = true;
		document.forms[0].txtQTY_OTHER.value = "";
	}
	else
	{
		document.forms[0].txtQTY_OTHER.disabled = false;
	}	
}

function launchPDF(fileJobNumber)
{
	if(fileJobNumber != "_none")
	{
		window.open("/_uploads/" + fileJobNumber + ".pdf");
	}
	else
	{	
		alert("Please choose a Job Number, then click Submit.");
	}
}

function deleteOption(object,index) {
    object.options[index] = null;
}

function addOption(object,text,value) {
    var defaultSelected = true;
    var selected = true;
    var optionName = new Option(text, value, defaultSelected, selected)
    object.options[object.length] = optionName;
}

function copySelected(fromObject,toObject) {
    for (var i=0, l=fromObject.options.length;i<l;i++) {
        if (fromObject.options[i].selected)
            addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
    }
    for (var i=fromObject.options.length-1;i>-1;i--) {
        if (fromObject.options[i].selected)
            deleteOption(fromObject,i);
    }
}

function copyAll(fromObject,toObject) {
    for (var i=0, l=fromObject.options.length;i<l;i++) {
        addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
    }
    for (var i=fromObject.options.length-1;i>-1;i--) {
        deleteOption(fromObject,i);
    }
}

function selectAllValues()
{
  List = document.forms[0].txtCHOICE;
  for (i=0;i<List.length;i++)
  {
     List.options[i].selected = true;
  }
  document.forms[0].submit();
}	

function moveup(list) {
	var daflag = false
	for (var i = 0; i <= list.options.length-1; i++) {
		if (!list[i].selected) {
			daflag = true
		}
		if (list[i].selected && daflag) {
			list.insertBefore(list[i],list[i-1])
		}
	}
}
function movedown(list) {
	var daflag = false
	for (var i = list.options.length-1; i >= 0; i--) {
		if (!list[i].selected) {
			daflag = true
		}
		if (list[i].selected && daflag) {
			list.insertBefore(list[i],list[i+2])
		}
	}
}

function DeciderLaunch()
{
	sS = document.forms["frmDecider"].sS.value;
	sF = document.forms["frmDecider"].sF.value;
	sW = document.forms["frmDecider"].sW.value;
	sO = document.forms["frmDecider"].sO.value;
	cS = document.forms["frmDecider"].cS.value;
	cF = document.forms["frmDecider"].cF.value;
	cW = document.forms["frmDecider"].cW.value;
	cO = document.forms["frmDecider"].cO.value;
	savF = document.forms["frmDecider"].savF.value;
	savIDNAME = document.forms["frmDecider"].savIDNAME.value;
	savCNAME = document.forms["frmDecider"].savCNAME.value;
	assignID = document.forms["frmDecider"].assignID.value;
	eval("window.open(\"/_inc/_decider/decider.asp?sS=" + sS + "&sF=" + sF + "&sW=" + sW + "&sO=" + sO + "&cS=" + cS + "&cF=" + cF + "&cW=" + cW + "&cO=" + cO + "&assignID=" + assignID + "&savF=" + savF + "&savIDNAME=" + savIDNAME + "&savCNAME=" + savCNAME + "\",\"\",\"height=400,width=500,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0\")")
}

function setSubMenu(sMenuName)
{
	eval("document.getElementById(\"" + sMenuName + "\").style.visibility = \"visible\";");	
}

function changeAsSeen(imgBaseName)
{
	document.imgMain.src = "images/" + imgBaseName + "_main.jpg";	
}

function swapAltView(imgBaseName, skuNumber)
{
	document.AltView.src = "images/products/" + imgBaseName;
	document.getElementById("divSKU").innerText = skuNumber;
}

function openZoom(simgFile)
{
		eval("window.open(\"pd_product_zoom.asp?imgFile=" + simgFile + "\",\"\",\"height=420,width=420,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=0,top=0\")")
}

function openSwatchZoom(simgFile)
{
	snewFile = simgFile.substring(simgFile.lastIndexOf("/")+1,simgFile.indexOf("_100px.gif"));
	snewFile = snewFile + "_5in.gif";
		eval("window.open(\"pd_swatch_zoom.asp?imgFile=" + snewFile + "\",\"\",\"height=335,width=325,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0\")")
}

function validateLogin()
{
	if(document.forms[0].emailaddress.value == "" || document.forms[0].password.value == "")
	{
		alert("Fill in all fields and click Submit.");
	}
	else
	{		
		document.forms[0].submit();
	}	
}

function validateChangePassword()
{
	if(document.forms[0].oldpassword.value == "" || document.forms[0].password.value == "" || document.forms[0].confirmpassword.value == "")
	{
		alert("Fill in all fields and click Submit.");
	}
	else
	{		
		if(document.forms[0].password.value == document.forms[0].confirmpassword.value)
		{
			document.forms[0].submit();
		}
		else
		{
			alert('Password and Confirm Password do not match.');
		}
	}	
}

function validateForgot()
{
	if(document.forms[0].emailaddress.value == "")
	{
		alert("Fill in the email field and click Submit.");
	}
	else
	{		
		document.forms[0].submit();
	}	
}

function validateCreateAccount()
{
	if(document.forms[0].emailaddress.value == "" || document.forms[0].password.value == "" || document.forms[0].confirmpassword.value == "")
	{
		alert("Fill in all fields and click Submit.");
	}
	else
	{		
		if(document.forms[0].password.value == document.forms[0].confirmpassword.value)
		{
			document.forms[0].submit();
		}
		else
		{
			alert('Password and Confirm Password do not match.');
		}
	}
}

function showInformation(slayername)
{
	if(slayername == "productinformationdimensions")
	{
		document.getElementById(slayername).style.visibility = "visible";
		document.getElementById("productinformationfeatures").style.visibility = "hidden";
		document.getElementById("productinformationpaulaspick").style.visibility = "hidden";
		document.getElementById("productinformationfeatureshead").style.backgroundColor = "#FFFEF3";
		document.getElementById("productinformationdimensionshead").style.backgroundColor = "#f4f3e8";
		document.getElementById("productinformationpaulaspickhead").style.backgroundColor = "#FFFEF3";		

 	}
	else if(slayername == "productinformationfeatures")
	{
		document.getElementById(slayername).style.visibility = "visible";
		document.getElementById("productinformationdimensions").style.visibility = "hidden";
		document.getElementById("productinformationpaulaspick").style.visibility = "hidden";
		document.getElementById("productinformationfeatureshead").style.backgroundColor = "#f4f3e8";
		document.getElementById("productinformationdimensionshead").style.backgroundColor = "#FFFEF3";
		document.getElementById("productinformationpaulaspickhead").style.backgroundColor = "#FFFEF3";			
	}
	else if(slayername == "productinformationpaulaspick")
	{
		document.getElementById(slayername).style.visibility = "visible";
		document.getElementById("productinformationfeatures").style.visibility = "hidden";
		document.getElementById("productinformationdimensions").style.visibility = "hidden";
		document.getElementById("productinformationfeatureshead").style.backgroundColor = "#FFFEF3";
		document.getElementById("productinformationdimensionshead").style.backgroundColor = "#FFFEF3";
		document.getElementById("productinformationpaulaspickhead").style.backgroundColor = "#f4f3e8";			
	}	
}

function popupImage800x600(imageName)
{
	if(imageName != "")
	{
	eval("window.open('imagepopup800x600.asp?imgname=" + imageName + "',null,'height=600,width=800,location=no,scrollbars=no,menu=no,resizable=no');");
	}
	else
	{
		alert("No Larger image is available at this time");
	}
}

function popupImage600x800(imageName)
{
	if(imageName != "")
	{
	eval("window.open('imagepopup600x800.asp?imgname=" + imageName + "',null,'height=800,width=600,location=no,scrollbars=no,menu=no,resizable=no');");
	}
	else
	{
		alert("No Larger image is available at this time");
	}
}

function popupImage400x400(imageName)
{
	eval("window.open('imagepopup400x400.asp?imgname=" + imageName + "',null,'height=400,width=400,location=no,scrollbars=no,menu=no,resizable=no');");
}

function setaltView(mainIMG,zoomImage)
{
	document.productmainimage.src = "images/Main/" + mainIMG;
	currentView = zoomImage;
}

function popupEmail(prodID)
{
	eval("window.open('emailable.asp?prodID=" + prodID + "',null,'height=98,width=322,location=no,scrollbars=no,menu=no,resizable=no');");
}

function popupImage577x785(imageName)
{
	eval("window.open('imagepopup577x785.asp?imgname=" + imageName + "',null,'height=785,width=577,location=no,scrollbars=no,menu=no,resizable=no');");
}

function popupPrint(prodID)
{
	eval("window.open('printable.asp?prodID=" + prodID + "',null,'height=775,width=961,location=no,scrollbars=no,menu=no,resizable=no');");
}

function printy()
{
		print();
		self.close();
}

function validateContactUs()
{
	if(document.forms[0].txtfirstname.value == "" || document.forms[0].txtlastname.value == "" || document.forms[0].txtaddress1.value == "" || document.forms[0].txtcity.value == "" || document.forms[0].txtstate.value == "" || document.forms[0].txtpostalcode.value == "" || document.forms[0].txtemailaddress.value == ""  || document.forms[0].txtcomment.value == "" )
	{
		alert("Fill in all fields and click Submit.");
	}
	else
	{		
		document.forms["contactusform"].submit();
	}
}

function whichView(imageName)
{
	if(imageName.lastIndexOf("800x600") != -1)
	{
		popupImage800x600(imageName);
	}
	else if(imageName.lastIndexOf("600x800") != -1)
	{
		popupImage600x800(imageName);
	}
	else
	{
		popupImage800x600(imageName);
	}
}