var message="Copyright of Nigel Cosway Photography."; 
document.onmousedown=explorer;
document.onmouseup=moz;
document.oncontextmenu=new Function("return false");
function msg() {
	 alert(message); 
	 return false;
}
function explorer() {
	 if (event.button == "2" || event.button == "3") {
		 msg();
	}
}
function moz(e) {
	 if (document.layers || (document.getElementById && !document.all)) {
		 if (e.which == "2" || e.which == "3") {
			 msg();
		}
	}
}

function openNewWindow1(obj) {
  popupWin = window.open(obj, 'open_window', 'menubar=0, toolbar=0, location=0, directories=0, status=0, scrollbars, resizable=0, dependent=0, width=450, height=630, left=5, top=5')
}

function openNewWindow2(obj) {
  popupWin = window.open(obj, 'open_window', 'menubar=0, toolbar=0, location=0, directories=0, status=0, scrollbars, resizable=0, dependent=0, width=840, height=565, left=5, top=5')
}

function SetBG(val1,val2){
	if(document.getElementById(val2).checked==true){
		document.getElementById(val1).style.backgroundColor='#F75454';
	}else{
		document.getElementById(val1).style.backgroundColor='';
	}
}

function AddToCart(val1,val2){
	if(!document.getElementById(val2).checked){
		document.getElementById(val2).checked=true;
		document.getElementById(val1).style.backgroundColor='#F75454';
	}else{
		document.getElementById(val2).checked=false;
		document.getElementById(val1).style.backgroundColor='';
	}
}


function RemoveFromCart(val){
	document.getElementById('remove_photo').value=val;
	document.form_1.submit();
}

function ValidateCart(){
	var x=document.getElementsByTagName("input").length;
	var count_chx=0;
	for(var y=0; y<x; y++){
		if(document.getElementsByTagName("input")[y].className=='chx'){
			var div_id=document.getElementsByTagName("input")[y].id;
			if(document.getElementById(div_id).checked){
				count_chx+=1;
			}
		}
	}
	if(count_chx==0){
		alert('Please make a selection from the photos in this event to complete your order.');
		return false;
	}else{
		document.form_1.submit();
		return true;
	}
}

function ValidateOrder(val1,val2){
	if (!document.getElementById('order_name').value){
		alert('Please enter your full name.');
		document.getElementById('order_name').focus();
		return false;
	}
	if (!document.getElementById('order_email').value){
		alert('Please enter your contact email address.');
		document.getElementById('order_email').focus();
		return false;
	}
	
	if (!document.getElementById('order_email').value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) {
		alert("The email address entered does not appear to be valid.\nPlease re-enter the email address.");
		document.getElementById('order_email').focus();
		return false;
	}
	
	
	if (!document.getElementById('order_contact').value){
		alert('Please enter a contact number.');
		document.getElementById('order_contact').focus();
		return false;
	}
	if (!document.getElementById('order_address1').value){
		alert('Please enter address.');
		document.getElementById('order_address1').focus();
		return false;
	}
	if (!document.getElementById('order_suburb').value){
		alert('Please enter your suburb.');
		document.getElementById('order_suburb').focus();
		return false;
	}
	if (!document.getElementById('order_province').value){
		alert('Please enter your province.');
		document.getElementById('order_province').focus();
		return false;
	}
	if (!document.getElementById('order_postcode').value){
		alert('Please enter your postcode.');
		document.getElementById('order_postcode').focus();
		return false;
	}
	if(val1==1){
		var conf=confirm('WARNING: Your order is less than the minimum amount of '+val2+' photos.\nTo continue with the order click on the OK button.\nTo return to the event and add additional photos click on the Cancel button.');
		if(conf){
			return true;
		}else{
			return false;
		}
	}
}

function VerifyForm() {
	if (!document.form1.name.value || !document.form1.email.value || !document.form1.subject.value || !document.form1.date_of_event.value || !document.form1.message.value || !document.form1.option.value) {
		alert("Some information is missing. Please complete all fields.");
		return false;
	}
	if (document.form1.email.value.indexOf(".") == -1 || document.form1.email.value.indexOf("@") == -1) {
		alert("The email address you have entered is invalid.");
		return false;
	}
}

function RunSWF4() {
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="797" height="204">\n');
   document.write('<param name="movie" value="./images/nigel_banner_flash_4.swf" />\n');
   document.write('<param name="quality" value="high" />\n');
   document.write('<param name="bgcolor" value="black" />\n');
   document.write('<param NAME="wmode" VALUE="transparent">\n');
   document.write('<embed src="./images/nigel_banner_flash_4.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="797" height="204"></embed>\n');
   document.write('</object>\n');
}

var timeout         = 200;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;