<!--
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Copyright PaperGarden.co.za - All Rights Reserved.\nUnauthorized use of Content & Images is strictly Prohibited";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

function validateSearch()
{
	fv = new formValidator();
	
	if (fv.isEmpty("keyword"))
		fv.raiseError("Please enter a word or phrase to search on.");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function bookmarkUs() 
{
	window.external.AddFavorite('http://www.papergarden.co.za', 'Paper Garden - The Art of Expression!');
}

function validateContactForm()
{
	fs =  new formValidator();
	
	if (fs.isEmpty("fullname"))
		fs.raiseError("Your fullname must be specified.");
		
	if (fs.isEmpty("email"))
		fs.raiseError("An email address must be specified");
		
  	if (!fs.isEmailAddress("email"))
		fs.raiseError("A valid email address must be specified");
				
	if (fs.isEmpty("message"))
		fs.raiseError("Comment(s)/ Question(s) must be specified.");
		
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateAccount()
{

	fv = new formValidator();
	
	if (fv.isEmpty("last_name"))
		fv.raiseError("Please specify your last name");
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your first name");
			
	if (fv.isEmpty("username"))
		fv.raiseError("Please specify a username");	
		
	if (fv.isEmpty("address_1"))
		fv.raiseError("Please specify an address");	
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify an city");	
		
	if (fv.isEmpty("state"))
		fv.raiseError("Please specify an province");	

	if (fv.isEmpty("zip"))
		fv.raiseError("Please specify an zip code");	
		
	if (fv.isEmpty("phone_1"))
		fv.raiseError("Please specify telephone number");	
		
	if (fv.isEmpty("user_email"))
		fv.raiseError("Please specify an email address");
	else
	{
		if (!fv.isEmailAddress("user_email"))
			fv.raiseError("Please specify a valid email address");
	}

	password1 = fv.findObj("password_1");
	password2 = fv.findObj("password_2");
	
	if (password1.value != password2.value)
		fv.raiseError("The passwords specified do not match.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateRegistration()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("last_name"))
		fv.raiseError("Please specify your Surname");
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your First Name");
			
	if (fv.isEmpty("username"))
		fv.raiseError("Please specify a username");
	
	if (fv.isEmpty("password_1"))
		fv.raiseError("Please specify a password");
	
	/*
	if (fv.isEmpty("address_1"))
		fv.raiseError("Please specify your address");
		*/
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify a city");
		/*
	if (fv.isEmpty("state"))
		fv.raiseError("Please specify a province");
		*/
	if (fv.isEmpty("zip"))
		fv.raiseError("Please specify a Postal Code");
		
	if (fv.isEmpty("phone_1"))
		fv.raiseError("Please specify a phone number");
		
	if (fv.isEmpty("user_email"))
		fv.raiseError("Please specify an email address");
	else
	{
		if (!fv.isEmailAddress("user_email"))
			fv.raiseError("Please specify a valid email address");
	}

	password1 = fv.findObj("password_1");
	password2 = fv.findObj("password_2");
	
	if (password1.value != password2.value)
		fv.raiseError("The passwords specified do not match.");
	
	// check further registration fields	

	if (fv.isEmpty("event_date"))
		fv.raiseError("Please specify the date that the function will take place.");
	else
	{
		// date validation
		var functionDate = new String(fv.findObj("event_date").value);
		var yr = functionDate.slice(0, functionDate.indexOf("-"));
		var mnth = functionDate.slice(functionDate.indexOf("-")+1, functionDate.lastIndexOf("-"));
		var day = functionDate.slice(functionDate.lastIndexOf("-")+1, functionDate.length);
		var postedDate = yr + mnth + day;
		
		var thisDate = new Date();
		var nowYr = thisDate.getFullYear();
		var nowMnth = (thisDate.getMonth().toString().length == 1 ? "0"+thisDate.getMonth() : thisDate.getDate());
		var today = (thisDate.getDate().toString().length == 1 ? "0"+thisDate.getDate() : thisDate.getDate());
		var todaysDate = nowYr + "" + nowMnth + "" + today;
		
		//alert (todaysDate + " - " + postedDate);
		if (todaysDate > postedDate)
			fv.raiseError("Please check your function date as it cannot be in the past.");
	}
	
	if (fv.isEmpty("num_guests"))
		fv.raiseError("Please indicate the approx. number of guests that will attend your function.");
	
	if (!fv.isCheckedRadio("formality"))
		fv.raiseError("Please indicate the formal style or formality of the function.");
	
	if (!fv.isCheckedRadio("tone"))
		fv.raiseError("Please indicate the tone of the function.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateLogin()
{
	fv = new formValidator();
	
	if (fv.isEmpty("login_username"))
		fv.raiseError("Please specify a username");
		
	if (fv.isEmpty("login_password"))
		fv.raiseError("Please specify a password");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateRecommendForm()
{
	fs = new formValidator();
	
	if (fs.isEmpty("your_name"))
		fs.raiseError("Your name must be specified.");
		
	if (!fs.isEmpty("your_email"))
	{
		if (!fs.isEmailAddress("your_email"))
			fs.raiseError("Your email address must be a valid email address.");
	}
	else
		fs.raiseError("Your email address must be specified.");
		
	if (fs.isEmpty("friend_name"))
		fs.raiseError("Your friend's name must be specified.");
	if (fs.isEmpty("friend_email"))
		fs.raiseError("Your friend's email address must be specified.");
	if (!fs.isEmailAddress("friend_email"))
		fs.raiseError("Your friends email address must be a valid email address.");
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}

function checkTerms()
{
	fs = new formValidator();
	
	if (!fs.isChecked("terms_read"))
		fs.raiseError("Please read our Terms & Conditions, Thank You");
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}

function termsAndConditions()
{
	window.open('terms-and-conditions.php', '', 'resizable=no,scrollbars=yes,width=575,height=580');
}

function validateCheckoutFields()
{
	fs = new formValidator();
	
	if (fs.isEmpty("order_payment_name"))
		fs.raiseError("Please provide the Name on The Card.");

	if (fs.isEmpty("payment_method_id"))
		fs.raiseError("Please select a method of payment.");
		
	if (fs.isEmpty("order_payment_number"))
		fs.raiseError("Please provide the credit card number.");
	
	monthExpIdx = document.Checkout.order_payment_expire_month.selectedIndex;
	yearExp = document.Checkout.order_payment_expire_year.value;

	if (monthExpIdx == 0)
		fs.raiseError("Please provide the expiry-month of the credit card.");
		
	//check card dates!
	
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function showPic(imgName) 
{
	if (ns3up || ie4up) 
		imgOn = ("" + imgName);
		
	document.mainimg.src = imgOn;
}