function shownew()
{	
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.action="photodelivery.php";
	document.fr1.submit();
}

function n_newsearch(a)
{
	document.fr1.searchfield.value=a;
	newsearch();
}

function home()
{
	if (document.fr1.customerid.value<=0)
	{
		document.location="index.html";
	}
	else
	{
		document.fr1.action="index.php";	
		document.fr1.submit();		
	}
}
function submitorder()
{
	if (!checkblnk(document.fr1.firstname)) return;	
	if (!check_name(document.fr1.firstname)) return;	
	if (!checkblnk(document.fr1.lastname)) return;
	if (!check_name(document.fr1.lastname)) return;	
	if (!checkblnk(document.fr1.email)) return;
        if (!check_email(document.fr1.email)) return;
	if (!checkblnk(document.fr1.company)) return;
        if (!check_name(document.fr1.company)) return;
        //if (!checkblnk(document.fr1.fax)) return;
        //if (!check_special(document.fr1.fax)) return;
	if (!checkblnk(document.fr1.dayphone)) return;
	if (!check_number(document.fr1.dayphone)) return;
	if (!checkblnk(document.fr1.address1)) return;
	if (!check_special(document.fr1.address1)) return;
	if (!checkblnk(document.fr1.city)) return;
	if (!check_special(document.fr1.city)) return;
	if (!checkblnk(document.fr1.state)) return;
	if (!check_special(document.fr1.state)) return;
	if (!checkblnk(document.fr1.zip)) return;
	if (!check_special(document.fr1.zip)) return;
	if (!checkblnk(document.fr1.country)) return;
	if (!check_special(document.fr1.country)) return;
	if (!checkblnk(document.fr1.billfirst)) return;
	if (!check_name(document.fr1.billfirst)) return;
	if (!checkblnk(document.fr1.billlast)) return;
	if (!check_name(document.fr1.billlast)) return;
	if (!checkblnk(document.fr1.baddress1)) return;
	if (!check_special(document.fr1.baddress1)) return;
	//if (!checkblnk(document.fr1.baddress2)) return;
	//if (!check_special(document.fr1.baddress2)) return;
	if (!checkblnk(document.fr1.bcity)) return;
	if (!check_special(document.fr1.bcity)) return;
	if (!checkblnk(document.fr1.bstate)) return;
	if (!check_special(document.fr1.bstate)) return;
	if (!checkblnk(document.fr1.bzip)) return;
	if (!check_special(document.fr1.bzip)) return;
	if (!checkblnk(document.fr1.bcountry)) return;
	if (!check_special(document.fr1.bcountry)) return;
	if (!check_special(document.fr1.pno)) return;
	if (!check_special(document.fr1.jno)) return;		
	if (!checkblnk(document.fr1.cardnumber)) return;
	if (!check_number(document.fr1.cardnumber)) return;	
	if (!checkblnk(document.fr1.nameoncard)) return;
	if (!check_name(document.fr1.nameoncard)) return;	
	if (!document.fr1.cardname[4].checked)
	{
        	if (!check_special(document.fr1.cvm)) return;		
		if (!checkblnk(document.fr1.expdate)) return;
	}
        
	
	if (!document.fr1.confirmme.checked) {alert('You must agree to the Terms and Conditions before continuing.');document.fr1.confirmme.focus();return;}
	document.fr1.todo.value="confirmorder";		
	document.fr1.action="checkout.php";	
	document.fr1.submit();	
	return;

}
function checkout1()
{
	document.fr1.todo.value="checkout";		
	document.fr1.action="checkout.php";	
	document.fr1.submit();	
}
function emailnow()
{
	if (!checkblnk(document.fr1.to)) return false;	
	if (!checkblnk(document.fr1.from)) return false;
	if (!checkblnk(document.fr1.subject)) return false;
	if (!checkblnk(document.fr1.message)) return false;
	document.fr1.mylid.value=document.fr1.Lightbox.value;
	document.fr1.todo.value="emailsend";		
	document.fr1.action="emailme.php";	
	document.fr1.submit();	
	return true;
}

function emaillight()
{
		document.fr1.todo.value="emailme";		
		document.fr1.action="emailme.php";	
		document.fr1.submit();	
}
function checkent(e)
{
	var characterCode;
	if(e && e.which){
		e = e;
	characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}
	if(characterCode == 13){ 
		return login3();
	}
	else{
		return true;
	}
}


function checkEnter(e){ //e is event object passed from function invocation 
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
return newsearch1();

}
else{
return true 
}

} 

function rename()
{
	var newname=prompt("Enter new name of Lightbox","");
	if (newname!=null)	
	if (newname!="" && newname!="null" && newname!="undefined")
	{
		document.fr1.todo.value="rename";
		document.fr1.imageno.value=newname;
		document.fr1.action="light.php";	
		document.fr1.submit();
		
	}
}
function deletelight()
{
	
	if (confirm("Are you sure you want to delete this Lightbox?"))
	{
		document.fr1.todo.value="deletelight";
		document.fr1.action="light.php";	
		document.fr1.submit();
	}
	
}
function createnew()
{
	var newname=prompt("Enter name of new Lightbox to create","");	
	if (newname!=null)	
	if (newname!=""  && newname!="null" && newname!="undefined")
	{
		document.fr1.todo.value="addnew";
		document.fr1.imageno.value=newname;
		document.fr1.action="light.php";	
		document.fr1.submit();
		
	}
}
function changeimageto(imageid,srno,previousid)
{
	
	document.fr2.todo.value="move";
	document.fr2.move.value=imageid;
	document.fr2.previousid.value=previousid;
	document.fr2.mylid.value=document.fr1.mylid.value;
	eval("document.fr2.lightboxid.value=document.fr2.mylid1"+srno+".value");
	document.fr2.action="light.php";
	document.fr2.submit();
}
function changedlightbox()
{
	document.fr1.action="light.php";
	document.fr1.submit();
}
function calllight()
{
	document.fr1.action="lightbox.php";
	document.fr1.submit();
}
function callview()
{
	document.fr1.action="view.php";
	document.fr1.submit();
}

function trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function checkblnk(a)
{
	
	if (trim(a.value)=="")
	{
		alert("Please enter value");
		a.focus();
		return false;
	}
	return true;
}

function checkblnk_m(a,b)
{

	
	if (trim(a.value)=="")
	{
		alert("Please enter value for "+b);
		a.focus();
		return false;
	}
	return true;
}


function loginnow()
{
		if (!checkblnk_m(document.fr1.name,"UserName")) return;
		if (!check_username(document.fr1.name)) return;
		if (!checkblnk_m(document.fr1.password,"PassWord")) return;
		if (!check_special(document.fr1.password)) return;
		if (!checkblnk_m(document.fr1.password2,"Confirm Password")) return;
		if (!check_special(document.fr1.password2)) return;
		if (document.fr1.password.value!=document.fr1.password2.value) {document.fr1.password2.focus();alert("Password does not match");return;}
		if (!checkblnk_m(document.fr1.firstname,"First Name")) return;
		if (!check_name(document.fr1.firstname)) return;
		if (!checkblnk_m(document.fr1.lastname,"Last Name")) return;
		if (!check_name(document.fr1.lastname)) return;
		if (!checkblnk_m(document.fr1.email,"Email")) return;
	        if (!check_email(document.fr1.email)) return;
		if (!checkblnk_m(document.fr1.company,"Company Name")) return;
		if (!check_name(document.fr1.company)) return;
		if (!checkblnk_m(document.fr1.rep2,"Company Type")) return;
		if (!check_special(document.fr1.rep2)) return;
		if (!checkblnk_m(document.fr1.companyposition,"Company Position")) return;
		if (!check_special(document.fr1.companyposition)) return;
		//if (!checkblnk(document.fr1.fax)) return;
	        //if (!check_special(document.fr1.fax)) return;
		if (!checkblnk_m(document.fr1.dayphone,"Phone")) return;
		if (!check_number(document.fr1.dayphone)) return;
		if (!checkblnk_m(document.fr1.address1,"Address Line 1")) return;
		if (!check_special(document.fr1.address1)) return;
		if (!checkblnk_m(document.fr1.city,"City")) return;
		if (!check_special(document.fr1.city)) return;
		if (!checkblnk_m(document.fr1.state,"State")) return;
		if (!check_special(document.fr1.state)) return;
		if (!checkblnk_m(document.fr1.zip,"Zip")) return;
		if (!check_special(document.fr1.zip)) return;
		if (!checkblnk_m(document.fr1.country,"Country")) return;
		if (!check_special(document.fr1.country)) return;
		if (!checkblnk_m(document.fr1.billfirst,"Billing First Name")) return;
		if (!check_name(document.fr1.billfirst)) return;
		if (!checkblnk_m(document.fr1.billlast,"Billing Last Name")) return;
		if (!check_name(document.fr1.billlast)) return;
		if (!checkblnk_m(document.fr1.baddress1,"Billing Address Line 1")) return;
		if (!check_special(document.fr1.baddress1)) return;
		if (!checkblnk_m(document.fr1.bcity,"Billing City")) return;
		if (!check_special(document.fr1.bcity)) return;
		if (!checkblnk_m(document.fr1.bstate,"Billing State")) return;
		if (!check_special(document.fr1.bstate)) return;
		if (!checkblnk_m(document.fr1.bzip,"Billing Zip")) return;
		if (!check_special(document.fr1.bzip)) return;
		if (!checkblnk_m(document.fr1.bcountry,"Billing Country")) return;
		if (!check_special(document.fr1.bcountry)) return;
		
	
	if (!checkblnk_m(document.fr1.register,"Register")) return;
	if (!document.fr1.terms.checked) {alert("You must agree to the Terms and Conditions before continuing.");return;}
	document.fr1.action="regi.php";
	document.fr1.todo.value="add";
	document.fr1.submit();
}

function check_name(a) {
	e=a.value;
	
	ok = "1234567890qwertyuiopasdfghjklzxcvbnm.-_QWERTYUIOPASDFGHJKLZXCVBNM ";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		alert('Wrong value. Special characters not allowed.');
		a.focus();
		return (false);
		}	
	} 
	return true;

}


function check_special(a) {
	e=a.value;
	ok = "&\"'<>";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))>=0){ 
		alert('Wrong value. No & " \' < > allowed.');
		a.focus();
		return (false);
		}	
	} 
	return true;

}

function check_username(a) {
	e=a.value;
	ok = "1234567890qwertyuiopasdfghjklzxcvbnm.-_QWERTYUIOPASDFGHJKLZXCVBNM@ ";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		alert('Wrong value. Special characters not allowed.');
		a.focus();
		return (false);
		}	
	} 
	return true;
}

function check_number(a) {
	e=a.value;
	ok = "1234567890-() ";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		alert('Wrong value. Only number ,- or () allowed.');
		a.focus();
		return (false);
		}	
	} 
	return true;

}

function check_email(a) {
	e=a.value;
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		alert('Wrong email address');
		a.focus();
		return (false);
		}	
	} 
	re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if (!e.match(re) && e.match(re_two)) {
		return true;		
	} 
	alert('Wrong email address');
	a.focus();
	return false;

}


function login3()
{
        if (!checkblnk(document.fr1.emails)) return;	
	if (!check_username(document.fr1.emails)) return;
	
	if (document.fr1.passwords.value=="")
	{
		alert("Please enter password");
		document.fr1.passwords.focus();
		return false;
	}
	document.fr1.action="logi.php";
	document.fr1.todo.value="login";
	document.fr1.submit();
	return true;
}

function login2()
{
	if (!checkblnk(document.fr1.emails)) return;	
	if (!check_username(document.fr1.emails)) return;	
	if (document.fr1.passwords.value=="")
	{
		alert("Please enter password");
		document.fr1.passwords.focus();
		return ;
	}
	document.fr1.action="logi.php";
	document.fr1.todo.value="login";
	document.fr1.submit();
	return ;
}

function logout()
{
	document.fr1.action="logi.php";
	document.fr1.todo.value="logout";
	document.fr1.submit();
}

function alogin()
{       
	document.fr1.action="logi.php";
	document.fr1.submit();
}
function registration()
{
	document.fr1.action="regi.php";
	document.fr1.submit();
}



function fullpage()
{
	document.fr1.action="search.php";
	document.fr1.submit();
}
function fullpager(a)
{
	document.fr1.action=a;
	document.fr1.submit();
}

function showpic(a)
{
	
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.action="searchresult.php";
	document.fr1.imageno.value=a;
	document.fr1.submit();
}
function showpage(a)
{
	document.fr1.imageno.value=a;
	document.fr1.action="search.php";
	document.fr1.curpage.value=a;
	document.fr1.submit();

}
function showpage1(a)
{
	document.fr1.imageno.value=a;
	document.fr1.action="lightbox.php";
	document.fr1.curpage.value=a;
	document.fr1.submit();
}
function showpage2(a)
{
	document.fr1.imageno.value=a;
	document.fr1.action="view.php";
	document.fr1.curpage.value=a;
	document.fr1.submit();
}

function callme()
{
	//document.fr1.curpage.value=document.fr1.sel.value;
	document.fr1.submit();
}
function newsearch1()
{
	if ((document.fr1.searchfield.value)=="")
	{
		alert("Please enter search term.");
		return false;
	}
	//document.fr1.search.value=document.fr1.searchfield.value;
	document.fr1.action="search.php";
	document.fr1.searchstring.value="";
	document.fr1.curpage.value=1;
	document.fr1.submit();
	return true;
}
function newsearch()
{
	
	if ((document.fr1.searchfield.value)=="")
	{
		alert("Please enter search term.");
		return ;
	}
	//document.fr1.search.value=document.fr1.searchfield.value;
	document.fr1.action="search.php";
	document.fr1.searchstring.value="";
	document.fr1.curpage.value=1;
	document.fr1.submit();
	return ;
}

function searchwithin()
{
	if ((document.fr1.searchfield.value)=="")
	{
		alert("Please enter search term.");
		//document.fr1.search.focus();
		return;
	}

	//document.fr1.search.value=document.fr1.searchfield.value;
	document.fr1.action="search.php";
	//document.fr1.searchstring.value="";
	document.fr1.curpage.value=1;
	document.fr1.submit();
}

function lightboxs(a)
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.todo.value="addlightbox";
	document.fr1.imageno.value=a;
	document.fr1.submit();
}
function dcomp(a)
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.forms[0].target="downloadnow";
	document.fr1.action="downcomp.php";
	document.fr1.imageno.value=a;
	document.fr1.submit();
	document.forms[0].target="_top";
}

function mylightbox()
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.action="lightbox.php";
	document.fr1.submit();
}

function mycart()
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}	
	document.fr1.action="mycart.php";
	document.fr1.submit();
}

function addtocart(a)
{

}
function addcart(a)
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.action="priceme.php";	
	document.fr1.imageno.value=a;
	document.fr1.submit();
}

function addcart1(a)
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.todo.value="addcart";
	document.fr1.action="priceme.php";
	document.fr1.imageno.value=a;
	document.fr1.submit();
}

function check_email_m(a,b) {
	e=a.value;
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		alert('Invalid email address');
		a.focus();
		return (false);
		}	
	} 
	re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if (!e.match(re) && e.match(re_two)) {
		return true;		
	} 
	alert('Invalid email address');
	a.focus();
	return false;

}
function deletelightbox(a,b)
{
	if (document.fr1.customerid.value<0)
	{
		alert("Please Login first.");

		document.fr1.action="login1.php";
		document.fr1.submit();
		return;
	}
	if (confirm("Are you sure you want to delete this image from your Lightbox?"))
	{	
		document.fr1.todo.value="deletelightboxdetail";
		document.fr1.action="light.php";
		document.fr1.imgid.value=a;
		document.fr1.id.value=b;
		document.fr1.submit();
	}
}
function checkbx()
{
	if (document.fr1.checkb.checked)
	{
		
		document.fr1.baddress1.value=document.fr1.address1.value;
		document.fr1.baddress2.value=document.fr1.address2.value;
		document.fr1.bcity.value=document.fr1.city.value;
		document.fr1.bstate.value=document.fr1.state.value;
		document.fr1.bzip.value=document.fr1.zip.value;
		document.fr1.bcountry.value=document.fr1.country.value;
		document.fr1.billfirst.value=document.fr1.firstname.value;
		document.fr1.billlast.value=document.fr1.lastname.value;

	}
}

function myaccount(a)
{
	if (document.fr1.customerid.value<=0)
	{
		alert("Please Login first.");

		document.fr1.action="logi.php";
		document.fr1.submit();
		return;
	}
	document.fr1.todo.value="";
	document.fr1.action="myaccount.php";	
	document.fr1.submit();
}
function loginnow1()
{
	
	if (!checkblnk(document.fr1.name)) return;
	if (!check_username(document.fr1.name)) return;
	if (!checkblnk(document.fr1.password)) return;
	if (!check_special(document.fr1.password)) return;
	if (!checkblnk(document.fr1.password2)) return;
	if (!check_special(document.fr1.password2)) return;
	if (document.fr1.password.value!=document.fr1.password2.value) {document.fr1.password2.focus();alert("Password does not match");return;}
	if (!checkblnk(document.fr1.firstname)) return;
	if (!check_name(document.fr1.firstname)) return;
	if (!checkblnk(document.fr1.lastname)) return;
	if (!check_name(document.fr1.lastname)) return;
	if (!checkblnk(document.fr1.email)) return;
        if (!check_email(document.fr1.email)) return;
	if (!checkblnk(document.fr1.company)) return;
	if (!check_name(document.fr1.company)) return;
	if (!checkblnk(document.fr1.rep2)) return;
	if (!check_special(document.fr1.rep2)) return;
	if (!checkblnk(document.fr1.companyposition)) return;
	if (!check_special(document.fr1.companyposition)) return;
	//if (!checkblnk(document.fr1.fax)) return;
	//if (!check_special(document.fr1.fax)) return;
	
	if (!checkblnk(document.fr1.dayphone)) return;
	if (!check_number(document.fr1.dayphone)) return;
	if (!checkblnk(document.fr1.address1)) return;
	if (!check_special(document.fr1.address1)) return;
	if (!checkblnk(document.fr1.city)) return;
	if (!check_special(document.fr1.city)) return;
	if (!checkblnk(document.fr1.state)) return;
	if (!check_special(document.fr1.state)) return;
	if (!checkblnk(document.fr1.zip)) return;
	if (!check_special(document.fr1.zip)) return;
	if (!checkblnk(document.fr1.country)) return;
	if (!check_special(document.fr1.country)) return;
	if (!checkblnk(document.fr1.billfirst)) return;
	if (!check_name(document.fr1.billfirst)) return;
	if (!checkblnk(document.fr1.billlast)) return;
	if (!check_name(document.fr1.billlast)) return;
	if (!checkblnk(document.fr1.baddress1)) return;
	if (!check_special(document.fr1.baddress1)) return;
	if (!checkblnk(document.fr1.bcity)) return;
	if (!check_special(document.fr1.bcity)) return;
	if (!checkblnk(document.fr1.bstate)) return;
	if (!check_special(document.fr1.bstate)) return;
	if (!checkblnk(document.fr1.bzip)) return;
	if (!check_special(document.fr1.bzip)) return;
	if (!checkblnk(document.fr1.bcountry)) return;
	if (!check_special(document.fr1.bcountry)) return;
	
	document.fr1.action="myaccount.php";
	document.fr1.todo.value="modify";
	document.fr1.submit();
}
function sendnow1()
{
	
	if (!checkblnk(document.fr1.name)) return;	
	if (!checkblnk(document.fr1.password)) return;
	if (!checkblnk(document.fr1.password2)) return;
	if (document.fr1.password.value!=document.fr1.password2.value) {document.fr1.password2.focus();alert("Password does not match");return;}
	if (!checkblnk(document.fr1.firstname)) return;
	if (!checkblnk(document.fr1.lastname)) return;
	if (!checkblnk(document.fr1.email)) return;
	
	document.fr1.action="companyacc.php";
	document.fr1.todo.value="modify";
	document.fr1.submit();
}
function showpg(a)
{
	document.forms[0].target="_top";
	document.fr1.action="comn.php?templatefl="+a;
	document.fr1.submit();
}

