/* function for showing and hiding each element according to the type of service*/

function hidecontainer(t)
{
if (t=='rep')
{	
	rep.style.display="";
	main.quan.style.display="";
	rep1.style.display="";
	main.CDPageNum.style.display="";
	rep2.style.display="";
	main.CDColor.style.display="";
	main.format.style.display="none";
	dvdrep1.style.display="none";
	main.running_time.style.display="none";
	dvdauth.style.display="none";
	main.region.style.display="none";
	dvdauth1.style.display="none";
	main.menu.style.display="none";
	dvdauth2.style.display="none";
	rep4.style.display="";
	main.InsertColor.style.display="";
	main.DVDWrap.style.display="none";
	dvdrep2.style.display="none";
}
if (t=='dvdrep')
{
	main.format.style.display="";
	dvdrep1.style.display="";
	rep.style.display="";
	main.quan.style.display="";
	rep1.style.display="none";
	main.CDPageNum.style.display="none";
	rep2.style.display="";
	rep4.style.display="none";
	main.InsertColor.style.display="none";
	main.CDColor.style.display="";
	main.running_time.style.display="none";
	dvdauth.style.display="none";
	main.region.style.display="none";
	dvdauth1.style.display="none";
	main.menu.style.display="none";
	dvdauth2.style.display="none";
	main.DVDWrap.style.display="";
	dvdrep2.style.display="";
}

	

if (t == 'dvdauth')
{
	main.running_time.style.display="";
	dvdauth.style.display="";
	main.region.style.display="";
	dvdauth1.style.display="";
	main.menu.style.display="";
	dvdauth2.style.display="";
	rep.style.display="none";
	main.quan.style.display="none";
	main.format.style.display="none";
	dvdrep1.style.display="none";
	main.CDPageNum.style.display="none";
	rep1.style.display="none";
	rep2.style.display="none";
	main.CDColor.style.display="none";
	main.InsertColor.style.display="none";
	rep4.style.display="none";
	main.DVDWrap.style.display="none";
	dvdrep2.style.display="none";
}


}

/* check values passed from the form */
function checkform() 
{
	if (document.main.name.value=='')
	{
		alert ("Please enter name ");
		document.main.name.focus();
		document.main.name.select();
		return false;
	}
	
	if (document.main.tel.value=='')
	{
		alert ("Please enter your contact number ");
		document.main.tel.focus();
		document.main.tel.select();
		return false;
	}
	
	//test if it's a valid email
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
 	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
 	if (reg1.test(document.main.email.value) || !reg2.test(document.main.email.value) || document.main.email.value=='') 
  	{
		alert ("Please enter a valid email address");
		document.main.email.focus();
		document.main.email.select();
		return false;
	}
	

	
	
}

//Opening thumbnails
 function open_window(text)
 {
 	function_txt="/pic.php?id=".concat(text);
 	
 	window.open(function_txt,'_blank','height=900,width=450,toolbar=no,location=no,menubar=no,titlebar=no');
 }
 
 //open window to send to friend
 function send_to_friend(t)
 {
	function_txt="/email.php?id=".concat(t); 
		window.open(function_txt,'_blank','height=450,width=450,toolbar=no,location=no,menubar=no,titlebar=no');
}

//check fields on email form
function checkemailform()
{
	if(document.main.name.value=='') {
		alert("Please enter your name");
		document.main.name.focus();
		document.main.name.select();
		return false;
	}
	
	//test if it's a valid email
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
 	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
 	if (reg1.test(document.main.email.value) || !reg2.test(document.main.email.value) || document.main.email.value=='') 
  	{
		alert ("Please enter your email address");
		document.main.email.focus();
		document.main.email.select();
		return false;
	}
	if (reg1.test(document.main.toemail.value) || !reg2.test(document.main.toemail.value) || document.main.email.value=='') 
  	{
		alert ("Please enter your friend's email address");
		document.main.toemail.focus();
		document.main.toemail.select();
		return false;
	}
	
}
function gen_open_window(link)
{
	window.open(link,'_blank','height=600,width=600,scrollbars=yes,toolbar=no,location=no,titlebar=no ');
}

function newsletter_check()
{
	if(document.sign_form.name.value.length <= 0) {
		alert("Please enter your name");
		document.sign_form.name.focus();
		document.sign_form.name.select();
		return false;
	}
	//test if it's a valid email
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
 	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
 	if (reg1.test(document.sign_form.email.value) || !reg2.test(document.sign_form.email.value) || document.sign_form.email.value=='') 
  	{
		alert ("Please enter your email address");
		document.sign_form.email.focus();
		document.sign_form.email.select();
		return false;
	}
	return true;
	
	
}

function hidedupform(t)
{
if (t=='bulk')
{	
	main.pack_option.style.display="";
	pack_option_text.style.display="";
}
if (t=='retail')
{	
	main.pack_option.style.display="none";
	pack_option_text.style.display="none";
}
}

function doublecheck() 
{
	if (document.main.name.value=='')
	{
		alert ("Please enter name ");
		document.main.name.focus();
		document.main.name.select();
		return false;
	}
	if (document.main.address.value=='')
	{
		alert ("Please enter address ");
		document.main.address.focus();
		document.main.address.select();
		return false;
	}
	if (document.main.city.value=='')
	{
		alert ("Please enter city ");
		document.main.city.focus();
		document.main.city.select();
		return false;
	}
	if (document.main.state.value=='')
	{
		alert ("Please enter state ");
		document.main.state.focus();
		document.main.state.select();
		return false;
	}
	if (document.main.zip.value=='')
	{
		alert ("Please enter zip ");
		document.main.zip.focus();
		document.main.zip.select();
		return false;
	}
	if (document.main.ctry.value=='')
	{
		alert ("Please enter country ");
		document.main.ctry.focus();
		document.main.ctry.select();
		return false;
	}
	if (document.main.tel.value=='')
	{
		alert ("Please enter phone number ");
		document.main.tel.focus();
		document.main.tel.select();
		return false;
	}
	if (document.main.email.value=='')
	{
		alert ("Please enter email ");
		document.main.email.focus();
		document.main.email.select();
		return false;
	}
	
		
		if (document.main.ship_pick.value=="yes" && document.main.shipname.value=='')
		{
			alert ("Please enter name ");
			document.main.shipname.focus();
			document.main.shipname.select();
			return false;
		}
	

	

	
}

function checkfreeofferform()
{
	if (document.main.name.value=='')
		{
			alert ("Please enter name ");
			document.main.name.focus();
			document.main.name.select();
			return false;
		}
		if (document.main.billaddress.value=='')
		{
			alert ("Please enter your billing address ");
			document.main.billaddress.focus();
			document.main.billaddress.select();
			return false;
		}
		
		if (document.main.tel.value=='')
		{
			alert ("Please enter your contact number ");
			document.main.tel.focus();
			document.main.tel.select();
			return false;
		}
		//test if it's a valid email
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	 	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	 	if (reg1.test(document.main.email.value) || !reg2.test(document.main.email.value) || document.main.email.value=='') 
	  	{
			alert ("Please enter a valid email address");
			document.main.email.focus();
			document.main.email.select();
			return false;
		}	
		if (document.main.referrer.value=='')
		{
			alert ("Please enter your referrer");
			document.main.referrer.focus();
			document.main.referrer.select();
			return false;
		}
		if (document.main.title.value=='')
		{
			alert ("Please enter the title of your project");
			document.main.title.focus();
			document.main.title.select();
			return false;
		}
		
		
		if(document.main.newsletter.checked!=1)
		{
			alert ("Our free DVD offer is only valid if you sign up our newsletter, please check the box to continue");
			document.main.newsletter.focus();
			document.main.newsletter.select();
			return false;
		}
		for (i=0;i<document.main.freedvd.length;i++)
		{
			var shipvalue1 = document.main.shipmeth1;
			var shipvalue2 = document.main.shipmeth2;
			
			if (document.main.freedvd[i].checked && document.main.freedvd[i].value == 'yes' && shipvalue1.options[shipvalue1.selectedIndex].value != 'willcall' && document.main.shipaddress.value=='' )
			{
				alert ("Please enter the shipping address ");
				document.main.shipaddress.focus();
				document.main.shipaddress.select();
				return false;
			}
			if (document.main.freedvd[i].checked && document.main.freedvd[i].value == 'no' && document.main.moredvd.value=='')
			{
				alert ("Please tell us about your additional DVD order ");
				document.main.moredvd.focus();
				document.main.moredvd.select();
				return false;
			}
			
			if (document.main.freedvd[i].checked && document.main.freedvd[i].value == 'no' && shipvalue2.options[shipvalue2.selectedIndex].value != 'willcall' && document.main.shipaddress.value=='' )
			{
				alert ("Please enter the shipping address ");
				document.main.shipaddress.focus();
				document.main.shipaddress.select();
				return false;
			}
		}
		
}

function copyshipaddress()
{
	if(document.main.sameasbilling.checked==1)
	{
		document.main.shipaddress.value=document.main.billaddress.value;
	}
	else
	{
		document.main.shipaddress.value='';
	}
}

function checkreferralemail()
{
	if(document.main.toemail.value=='') {
		alert("Please enter some email addresses");
		document.main.toemail.focus();
		document.main.toemail.select();
		return false;
	}
	
	
	
}


function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=500,scrollbars=yes');
return false;
}

function tooltip(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}