

function gotogallery()
{
	
window.location="gallery.php";	

}

function clearfield(field)
{

	var thefield=document.getElementById(field);
	if (thefield.value="Email Address")
	     thefield.value="";
		 
	if (thefield.value="Order Number")
		thefield.value="";
		
	thefield.focus();
	
		
}
function validate_customer_login(thisform)
{


var email_tx=document.getElementById("email_tx");
var order_no=document.getElementById("order_no");


  if (validate_email(email_tx,"Invalid email address!")==false)
    {email_tx.focus();return false;}  

  if (validate_not_blank(order_no,"Please enter your order number!")==false)
    {order_no.focus();return false;}  
	  
	  
}
 	
function deleteUpload(selected_project_id,path,file)
{
	if (confirm ("Are you sure you want to delete file, "+file+"?")==true)
	{
	//alert (selected_project_id);
	//alert(path);
	//alert(file);
	
	document.getElementById("selected_project_id").value=selected_project_id;
	document.getElementById("deletePath").value=path;
	document.getElementById("deleteFile").value=file;
	
	document.getElementById("rte").value="deleteUpload";
	document.forms.item(0).submit();
	}
}

	function upload(selected_project_id)
{
	//alert (selected_project_id);
	document.getElementById("selected_project_id").value=selected_project_id;
	document.getElementById("rte").value="upload";
	document.forms.item(0).submit();
}


function selectorder(selected_project_id)
{
	//alert (selected_project_id);
	document.getElementById("selected_project_id").value=selected_project_id;
	document.getElementById("rte").value="select_project";
	document.forms.item(0).submit();
}


function nextPage(offset)
{
	var recordsperpage=Number(document.getElementById("recordsPerPage").value);
	
	var newoffset=Number(document.getElementById("offset").value)+recordsperpage;
	document.getElementById("offset").value=newoffset;
	document.getElementById("rte").value="nextpage";
	document.forms.item(0).submit();
}

function prevPage(offset)
{
	var recordsperpage=Number(document.getElementById("recordsPerPage").value);
	var newoffset=Number(document.getElementById("offset").value)-recordsperpage;
	document.getElementById("offset").value=newoffset;
	document.getElementById("rte").value="prevpage";
	document.forms.item(0).submit();
}
function setOrderBy(orderBy)
{
	var orderby=document.getElementById("orderBy");
	orderby.value=orderBy; 
	alert(orderby.value);
	designer_search_projects();
}

function designer_search_projects()
{
	var rte=document.getElementById("rte");
	rte.value="designer_search_projects";
	document.forms.item(0).submit();
	
}

function sendacceptfinal()
{
document.forms.item(0).submit();

}

function validate_myproject_form(thisform)
{
//alert(1);
	var new_message=document.getElementById("message_tx");
	var rte=document.getElementById("rte");
	
	if (rte.value=="new_message")
	{
	  if (validate_not_blank(new_message,"Please enter a message before sending")==false)
		{new_message.focus();return false;}  
	}

}



function validCreditCard()
{
if (checkCreditCard(document.getElementById("cardnumber").value,document.getElementById("cardname").value)==false)
{
	document.getElementById("cardnumber1").value="";
	document.getElementById("cardnumber2").value="";
	document.getElementById("cardnumber3").value="";	
	document.getElementById("cardnumber4").value="";	
	document.getElementById("cardnumber").value="";	
	document.getElementById("cardnumber1").focus();
	
	return false;
}
else {return true;}
	  
}

function validate_payment_form(thisform)
{



document.getElementById("paymentMethod").value=document.getElementById("cardname").value.substring(0,1);
document.getElementById("cctype").value=document.getElementById("cardname").value.substring(0,1);
var submitter=document.getElementById("submitter");
var first_nm=document.getElementById("first_nm");
var last_nm=document.getElementById("last_nm");
var address1_tx=document.getElementById("address1_tx");
var city_nm=document.getElementById("city_nm");
var postal_cd=document.getElementById("bzip");
var sel_state_nm=document.getElementById("sel_state_nm");

var cardnum=document.getElementById("cardnumber");

document.getElementById("cardnumber").value=
	document.getElementById("cardnumber1").value+
	document.getElementById("cardnumber2").value+
	document.getElementById("cardnumber3").value+
	document.getElementById("cardnumber4").value;


//security code validation
/*
var securityCode=document.getElementById("securityCode");//get field as variable

var securityCodeLen=3;//most cards have 3 digit code
if (document.getElementById("cardname").value.substring(0,1)=="A")
	securityCodeLen=4;//American Express has 4 digit code

if (validate_security_code(securityCode,securityCodeLen,"Invalid Security Code!")==false)
    {securityCode.focus();return false;} 
	*/
//end security code validation

  if (validate_name(first_nm,"Invalid first name!")==false)
    {first_nm.focus();return false;}  

  if (validate_name(last_nm,"Invalid last name!")==false)
    {last_nm.focus();return false;}  
	  
  if (validate_address(address1_tx,"Invalid address! Please verify that length is 1-50 characters.",50)==false)
    {address1_tx.focus();return false;}  
		
  if (validate_address(city_nm,"Invalid city! Please verify that length is 1-30 characters.",30)==false)
    {city_nm.focus();return false;}  
	
   if (validate_state_nm(sel_state_nm,"Please select a state from the list.")==false)
  	{sel_state_nm.focus();return false;}
	
  if (validate_zip(postal_cd,"Invalid zip code! Please verify that length is 5 digits.")==false)
    {postal_cd.focus();return false;}  
 	

return validCreditCard();

}


function validate_form_envelope(thisform)
{
with (thisform)
  {
	  
	  if (validate_radio(env,"Please select an envelope design!")==false)
    		{env[0].focus();
			return false;}  
  }
}


function validate_form_stationary(thisform)
{
with (thisform)
  {
	  
	  if (validate_radio(stationary,"Please select a stationary design!")==false)
    		{stationary[0].focus();return false;}  
  }
}


function validate_form_card(thisform)
{
with (thisform)
  {
	  
	  if (validate_radio(card,"Please select a card!")==false)
    		{card[0].focus();return false;}  
  }
}

//validate entire customer info form prior to submit
function validate_form(thisform)
{
with (thisform)
  {
	  
  if (validate_name(hfirst_nm,"Invalid first name!")==false)
    {hfirst_nm.focus();
	hfirst_nm.style.color="red";
	hfirst_nm.style.fontWeight="bold";
	
	if (hfirst_nm.value.length==0 || hfirst_nm.value=="**required field**")
		hfirst_nm.value="**required field**";
		
	return false;
	}  
	else 	
	{
		hfirst_nm.style.color="black";
		hfirst_nm.style.fontWeight="normal";
		
	}

  if (validate_name(hlast_nm,"Invalid last name!")==false)
    {hlast_nm.focus();	hlast_nm.style.color="red";
	hlast_nm.style.fontWeight="bold";
	
	if (hlast_nm.value.length==0 || hlast_nm.value=="**required field**")
		hlast_nm.value="**required field**";
		
	return false;}  	
	else 	
	{
		hlast_nm.style.color="black";
		hlast_nm.style.fontWeight="normal";
		
	}
	  
  if (validate_address(haddress1_tx,"Invalid address! Please verify that length is 1-50 characters.",50)==false)
    {haddress1_tx.focus();haddress1_tx.style.color="red";
	haddress1_tx.style.fontWeight="bold";
	
	if (haddress1_tx.value.length==0 || haddress1_tx.value=="**required field**")
		haddress1_tx.value="**required field**";
		
		return false;}  	
	else 	
	{
		haddress1_tx.style.color="black";
		haddress1_tx.style.fontWeight="normal";
		
	}  
	
  if (validate_address(hcity_nm,"Invalid city! Please verify that length is 1-30 characters.",30)==false)
    {hcity_nm.focus();	hcity_nm.style.color="red";
	hcity_nm.style.fontWeight="bold";
		
	if (hcity_nm.value.length==0 || hcity_nm.value=="**required field**")
		hcity_nm.value="**required field**";
		
		return false;}  	
	else 	
	{
		hcity_nm.style.color="black";
		hcity_nm.style.fontWeight="normal";
		
	}   
	

	
	
  if (validate_zip(hpostal_cd,"Invalid zip code! Please verify that length is 5 digits.")==false)
    {hpostal_cd.focus();hpostal_cd.style.color="red";
	hpostal_cd.style.fontWeight="bold";
			
	if (hpostal_cd.value.length==0 || hpostal_cd.value=="**required field**")
		hpostal_cd.value="**required field**";
		
	return false;}  	
	else 	
	{
		hpostal_cd.style.color="black";
		hpostal_cd.style.fontWeight="normal";
		
	}   
	  
  if (validate_email(email_tx,"Not a valid e-mail address!")==false)
    {email_tx.focus();	
	email_tx.style.color="red";
	email_tx.style.fontWeight="bold";
			
	if (email_tx.value.length==0 || email_tx.value=="**required field**")
		email_tx.value="**required field**";
		
	return false;}  	
	else 	
	{
		email_tx.style.color="black";
		email_tx.style.fontWeight="normal";
		
	}  
	
  if (validate_email(email_tx2,"Not a valid e-mail address!")==false)
    {email_tx2.focus();email_tx2.style.color="red";
	email_tx2.style.fontWeight="bold";
			
	if (email_tx2.value.length==0 || email_tx2.value=="**required field**")
		email_tx2.value="**required field**";
		
	return false;}  	
	else 	
	{
		email_tx2.style.color="black";
		email_tx2.style.fontWeight="normal";
		
	}  
	
  if (validate_email2(thisform,"Email addresses did not match!")==false)
    {email_tx.focus();
			
	if (email_tx.value.length==0 || email_tx.value=="**required field**")
		email_tx.value="**required field**";
		
	
	return false;}  	
	else 	
	{
		email_tx.style.color="black";
		email_tx.style.fontWeight="normal";
		
	}
	
  if (validate_phone(phone_area_tx,"Area code contains illegal characters or not 3 is characters long.",3)==false)
  	{phone_area_tx.focus();phone_area_tx.style.color="red";
	phone_area_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		phone_area_tx.style.color="black";
		phone_area_tx.style.fontWeight="normal";
		
	}

  if (validate_phone(phone_prefix_tx,"Phone prefix contains illegal characters or not 3 is characters long.",3)==false)
  	{phone_prefix_tx.focus();phone_prefix_tx.style.color="red";
	phone_prefix_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		phone_prefix_tx.style.color="black";
		phone_prefix_tx.style.fontWeight="normal";
		
	}

  if (validate_phone(phone_ex_tx,"Phone extension contains illegal characters or not 4 is characters long.",4)==false)
  	{phone_ex_tx.focus();phone_ex_tx.style.color="red";
	phone_ex_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		phone_ex_tx.style.color="black";
		phone_ex_tx.style.fontWeight="normal";
		
	}
	

	
  if (validate_state_nm(hstate_nm,"Please select a state from the list.")==false)
  	{hstate_nm.focus();hstate_nm.style.color="red";
	hstate_nm.style.fontWeight="bold";return false;}  	
	else 	
	{
		hstate_nm.style.color="black";
		hstate_nm.style.fontWeight="normal";
		
	}



//company information

	
	
  if (validate_co_name(company_nm,"Invalid company name!")==false)
    {company_nm.focus();company_nm.style.color="red";
	company_nm.style.fontWeight="bold";
	
			
	if (company_nm.value.length==0 || company_nm.value=="**required field**")
		company_nm.value="**required field**";
		
	
	
	return false;}  	
	else 	
	{
		company_nm.style.color="black";
		company_nm.style.fontWeight="normal";
		
	}  
 
  if (validate_address(co_address1_tx,"Invalid company address! Please verify that length is 1-50 characters.",50)==false)
    {co_address1_tx.focus();co_address1_tx.style.color="red";
	co_address1_tx.style.fontWeight="bold";
				
	if (co_address1_tx.value.length==0 || co_address1_tx.value=="**required field**")
		co_address1_tx.value="**required field**";
		
	
	return false;}  	
	else 	
	{
		co_address1_tx.style.color="black";
		co_address1_tx.style.fontWeight="normal";
		
	}    
	
  if (validate_address(co_city_nm,"Invalid company city! Please verify that length is 1-30 characters.",30)==false)
    {co_city_nm.focus();
co_city_nm.style.color="red";
	co_city_nm.style.fontWeight="bold";
	
	if (co_city_nm.value.length==0 || co_city_nm.value=="**required field**")
		co_city_nm.value="**required field**";
	
	return false;}  	
	else 	
	{
		co_city_nm.style.color="black";
		co_city_nm.style.fontWeight="normal";
	
	}      
	
	
  if (validate_state_nm(co_state_nm,"Please select a company state from the list.")==false)
  	{co_state_nm.focus();co_state_nm.style.color="red";
	co_state_nm.style.fontWeight="bold";return false;}  	
	else 	
	{
		co_state_nm.style.color="black";
		co_state_nm.style.fontWeight="normal";
	
	}      
	
  if (validate_zip(co_postal_cd,"Invalid company zip code! Please verify that length is 5 digits.")==false)
    {co_postal_cd.focus();co_postal_cd.style.color="red";
	co_postal_cd.style.fontWeight="bold";return false;}  	
	else 	
	{
		co_postal_cd.style.color="black";
		co_postal_cd.style.fontWeight="normal";
		
	}        
	
   if (validate_phone(co_phone_area_tx,"Company area code contains illegal characters or is not 3 characters long.",3)==false)
  	{co_phone_area_tx.focus();co_phone_area_tx.style.color="red";
	co_phone_area_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		co_phone_area_tx.style.color="black";
		co_phone_area_tx.style.fontWeight="normal";
		
	}        

	
  if (validate_phone(co_phone_prefix_tx,"Company phone prefix contains illegal characters or is not 3 characters long.",3)==false)
  	{co_phone_prefix_tx.focus();co_phone_prefix_tx.style.color="red";
	co_phone_prefix_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		co_phone_prefix_tx.style.color="black";
		co_phone_prefix_tx.style.fontWeight="normal";
		
	}        

  if (validate_phone(co_phone_ex_tx,"Company phone extension contains illegal characters or is not 4 characters long.",4)==false)
  	{co_phone_ex_tx.focus();co_phone_ex_tx.style.color="red";
	co_phone_ex_tx.style.fontWeight="bold";return false;}  	
	else 	
	{
		co_phone_ex_tx.style.color="black";
		co_phone_ex_tx.style.fontWeight="normal";
		
	}
	
  if (co_fax_area_tx.value.length >0 && co_fax_area_tx.value!="NA" )  //only test fax numbers if fax area code contains something
  {
	  if (validate_phone(co_fax_area_tx,"Company fax area code contains illegal characters.",3)==false)
		{co_fax_area_tx.focus();co_fax_area_tx.style.color="red";
	co_fax_area_tx.style.fontWeight="bold";return false;}  	
		else 	
		{
			co_fax_area_tx.style.color="black";
			co_fax_area_tx.style.fontWeight="normal";
			
		}
	
	  if (validate_phone(co_fax_prefix_tx,"Company fax prefix contains illegal characters.",3)==false)
		{co_fax_prefix_tx.focus();co_fax_prefix_tx.style.color="red";
	co_fax_prefix_tx.style.fontWeight="bold";return false;}
		else 	
		{
			co_fax_prefix_tx.style.color="black";
			co_fax_prefix_tx.style.fontWeight="normal";
			
		}
	
	  if (validate_phone(co_fax_ex_tx,"Company fax extension contains illegal characters.",4)==false)
		{co_fax_ex_tx.focus();co_fax_ex_tx.style.color="red";
	co_fax_ex_tx.style.fontWeight="bold";return false;}  	
		else 	
		{
			co_fax_ex_tx.style.color="black";
			co_fax_ex_tx.style.fontWeight="normal";
			
		}
	
  }
	
	
  if (validate_email(co_email_tx,"Not a valid company e-mail address!")==false)
    {co_email_tx.focus();co_email_tx.style.color="red";
	co_email_tx.style.fontWeight="bold";return false;}
	else 	
	{
		co_email_tx.style.color="black";
		co_email_tx.style.fontWeight="normal";
		return true;
	}
	

//end of company information
	
  }
}



function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "-1";
	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) 
		{
			return radioObj[i].value;
		}
	}
	return "-1";
}


function validate_radio(field,alerttxt)
{
with (field)
  {
	  var theval=getCheckedValue(field);
	  
	  if (theval==-1)
    	{alert(alerttxt);return false;}
  else {return true;}
  }
}



function validate_state_nm (field, alerttext) 
{
	with (field)
	  {
		  if (value=="Select state")
		   {alert(alerttext);return false;}
		else {return true;}
	  }
	
}

function validate_address (field, alerttext,len) 
{
	
	with (field)
	  {
		  if (value.length<1 || value.length>len)
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}

function validate_zip (field, alerttext) 
{
	
	with (field)
	  {
		  if (value.length<5)
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}

function validate_co_name (field, alerttext) 
{
	
	with (field)
	  {
		  var illegalChars = /^[A-Z0-9 _]*$/; // allow any word character including spaces
		  
		  if (value.length<1 || illegalChars.test(value))
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}

function validate_not_blank (field, alerttext) 
{
	with (field)
	  {	 		  
		  if (value.length<3 )
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}


function validate_security_code (field,len, alerttext) 
{
	with (field)
	  {
		  var illegalChars = /[\W_]/; // allow only letters and numbers
		  
		  if (value.length!=len || illegalChars.test(value))
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}



function validate_name (field, alerttext) 
{
	with (field)
	  {
		  var illegalChars = /[\W_][-]/; // allow only letters and numbers
		  
		  if (value.length<1 || illegalChars.test(value))
		   {alert(alerttext);return false;}
		else {return true;}
	  }
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }



function validate_phone(field, alerttext,len)
{

	with (field)
	  {
		  
		
		if (! IsNumeric( value ) || value.length!=len ) 
			{alert(alerttext);return false;}
		else {return true;}

	  }
	  
}




//email address format
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;}
  }
}

//email confirmation on both fields
function validate_email2(thisform,alerttxt)
{
with (thisform)
  {
	  if (email_tx.value!=email_tx2.value)
    	{alert(alerttxt);return false;}
  else {return true;}
  }
}




//email
/*
function checkEmail(strng)
{
	error ="";
	var emailFilter=/^.+@.+\..{2,3,4,6}$/;
	if (!(emailFilter.test(strng))) 
	{ 
		   error = "Please enter a valid email address.\n";
	}
	return error;
}*/

//phone

function checkRadio2(theForm)
{
//check radio
	for (i=0, n=theForm.radios.length; i<n; i++) {
	   if (theForm.radios[i].checked) {
		  var checkvalue = theForm.radios[i].value;
		  break;
	   }
	}
	why += checkRadio(checkvalue);
}
 
function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;    
}


//check select
function checkDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = "You didn't choose an option from the drop-down list.\n";
    }    
return error;
} 

//check password
function checkPassword (strng) {
 var error = "";
 if (strng == "") 
 {
    error = "You didn't enter a password.\n";
 }
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 8)) 
	{
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) 
	{
      error = "The password contains illegal characters.\n";
    }
}


function validateSecurityCode(field,nextfield)
{
	len=3;
	cardType=document.getElementById("cardname").value;
	
	if (cardType=="American Express")
		len=4;
		
	checklength(len,field, nextfield);
	
}


function checklength(len,field, nextfield)
{
     if (field.value.length==len)
	 	{
			document.getElementById(nextfield).focus();
		}
}


function selectOptionByValue(selObj, value)
{

    for (options in selObj.options)
	{
		
        if (options.value == value)
		{
            options.selected = true;
            break;
		}
    }
 
}

	

// implementing a trim function for strings in javascript

<!--
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}



// end hiding contents -->



function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function projectsearch()
{
	document.getElementById('selected_project_id').value=-1;
	document.forms.item(0).submit();
}



