function externalLinks() {
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName( "a" );
		for (var i = 0; i < anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
	}
}  
window.onload =	externalLinks;

function verify_signupform() {
	var msg;
	var complete;
	var empty_fields = "";
	f = document.signup;
	if (f.jj_name.value.length < 1) {
		empty_fields += "\n -       your name";
		complete = false;
	}
	if (f.jj_email.value.length < 1) {
		empty_fields += "\n -       your email address";
		complete = false;
	}
	if (f.jj_phone.value.length < 1) {
		empty_fields += "\n -       your phone number";
		complete = false;
	}
	if (f.inv_a1.value.length < 1) {
		empty_fields += "\n -       your address";
		complete = false;
	}
	if (f.inv_postcode.value.length < 1) {
		empty_fields += "\n -       your postcode";
		complete = false;
	}
	if (f.inv_country.selectedIndex == 0) {
		empty_fields += "\n -       country";
		complete = false;
	}
	// NEW (APRIL 2009)
	
	if ((f.del_name.value.length > 0) && ((f.del_country.selectedIndex == 0) || (f.del_country.value.length<1))) {
		// We have a different delivery name, but no country!
		empty_fields += "\n -      delivery country";
		complete = false;
	}
	
	if (complete == false) {
		msg  = "========== Jaspal Jandu Photography ========== \n\n";
		msg += "In order to continue you must complete the following:  \n" + empty_fields + "\n";
		alert(msg);
		return false;
	} else {
		return true;
	}	
}

function pop(uri) {
	newwindow=window.open(uri,'name','height=400,width=400,top=15,left=15');
	return false;
}

function popTestimonials(uri) {
	newwindow=window.open(uri,'name','height=620,width=720,top=15,left=15,resizable=no,scrollbars=yes');
	return false;
}

function togglenews(ref) {
	newsref = "news" + ref;
	dotsref = "summary" + ref;
	if (document.getElementById(newsref).className == 'shownews') {
		document.getElementById(newsref).className = 'hidenews';
		document.getElementById(dotsref).style.display = 'block';
	} else {
		document.getElementById(newsref).className = 'shownews';
		document.getElementById(dotsref).style.display = 'none';
	}
	return false;
}


function launchhelp(url) {
	newWin = window.open(url,"helpppage", "toolbar=no,menubar=no,width=820,height=450,resizable=no,scrollbars=yes");
	newWin.focus();
}

function updateQuantities(menuObj, productRef){
   var i = menuObj.selectedIndex;
   var quantity = menuObj.options[i].value;
   nextpage = "update_quantities.php?ref=" + productRef + "&q=" + quantity;
   window.location =  nextpage;
	//alert(quantity);
}

function insertGalleryFlash(url) {
	flashHTML = ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="800" height="320" id="tech" align="middle">');
	flashHTML += ('<param name="allowScriptAccess" value="sameDomain" />');
	flashHTML += ('<param name="movie" value="' + url + '" />');
	flashHTML += ('<param name="bgcolor" value="#000000" />');
	flashHTML += ('<param name="quality" value="high" />');
	flashHTML += ('<embed src="' + url + '" quality="high" bgcolor="#000000" width="800" height="320" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	flashHTML += ('</object>');
	document.write (flashHTML);
}
function insertAnyFlash(url, w, h) {
	flashHTML = ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ w + '" height="' + h + '" id="tech" align="middle">');
	flashHTML += ('<param name="allowScriptAccess" value="sameDomain" />');
	flashHTML += ('<param name="movie" value="' + url + '" />');
	flashHTML += ('<param name="bgcolor" value="#0A0A0A" />');
	flashHTML += ('<param name="quality" value="high" />');
	flashHTML += ('<embed src="' + url + '" quality="high" bgcolor="#0A0A0A" width="' + w + '" height="' + h + '" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	flashHTML += ('</object>');
	document.write (flashHTML);
}


function verify_subscribeform() {
	var msg;
	var complete;
	var empty_fields = "";
	f = document.getElementById("mailing_list");
	if (f.mailing_Name.value.length < 1) {
		empty_fields += "\n -       your name";
		complete = false;
	}
	if (f.mailing_Email.value.length < 1) {
		empty_fields += "\n -       your email address";
		complete = false;
	}
	
	
	if (complete == false) {
		msg  = "========== Jaspal Jandu Photography ========== \n\n";
		msg += "In order to continue you must complete the following:  \n" + empty_fields + "\n";
		alert(msg);
		return false;
	} else {
		return true;
	}	
}
