
// Standard Dreamweaver JavaScript

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function HomeButtons(ELMT,state){
	if (state){
		document.getElementById(ELMT).style.backgroundColor = '#680066';
		document.getElementById(ELMT).style.color = '#FFFFFF';
	}	
	else {
		document.getElementById(ELMT).style.backgroundColor = 'transparent';
		document.getElementById(ELMT).style.color = '#680066';
	}
}
// Vlidation for newsletter subscription
function ValidateNewsletter(){
	if (window.document.NewsLetter.email.value == ''){
		alert('Your email address has not been entered\nPlease enter your email address');
		window.document.NewsLetter.email.focus();
		return false;}
	if (document.NewsLetter.email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.NewsLetter.email.focus();
		return false;}
	if (document.NewsLetter.email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.NewsLetter.email.focus();
		return false;}
	return true;
}
function ValidateFriend(){
	if (window.document.taf.email.value == ''){
		alert('Your email address has not been entered\nPlease enter your email address');
		window.document.taf.email.focus();
		return false;}
	if (document.taf.email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.taf.email.focus();
		return false;}
	if (document.taf.email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.taf.email.focus();
		return false;}

	if (window.document.taf.rec_email.value == ''){
		alert('Recipient email address has not been entered\nPlease enter your email address');
		window.document.taf.rec_email.focus();
		return false;}
	if (document.taf.rec_email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.taf.rec_email.focus();
		return false;}
	if (document.taf.rec_email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.taf.rec_email.focus();
		return false;}
	return true;
}
function ValidateReg(){
	if (window.document.Reg.email.value == ''){
		alert('Your email address has not been entered\nPlease enter your email address');
		window.document.Reg.email.focus();
		return false;}
	if (document.Reg.email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.Reg.email.focus();
		return false;}
	if (document.Reg.email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.Reg.email.focus();
		return false;}
	if (document.Reg.name.value == ""){
		alert('Please enter your name');
		window.document.Reg.name.focus();
		return false;}
	if (document.Reg.houseno.value == ""){
		alert('Please enter your house number or name');
		window.document.Reg.houseno.focus();
		return false;}
	if (document.Reg.address.value == ""){
		alert('Please enter your address');
		window.document.Reg.address.focus();
		return false;}
	if (document.Reg.postcode.value == ""){
		alert('Please enter your postcode');
		window.document.Reg.postcode.focus();
		return false;}
	if (document.Reg.password.value == ""){
		alert('Please enter a password');
		window.document.Reg.password.focus();
		return false;}
	return true;	
}
function ValidateDelivery(){
	if (document.goorder.del_to.value == ""){
		alert('Please enter a name');
		window.document.goorder.del_to.focus();
		return false;}
	if (document.goorder.del_houseno.value == ""){
		alert('Please enter a house number or name');
		window.document.goorder.del_houseno.focus();
		return false;}
	if (document.goorder.del_address.value == ""){
		alert('Please enter an address');
		window.document.goorder.del_address.focus();
		return false;}
	if (document.goorder.del_postcode.value == ""){
		alert('Please enter a postcode');
		window.document.goorder.del_postcode.focus();
		return false;}
	if (window.document.goorder.del_email.value == ''){
		alert('Your email address has not been entered\nPlease enter your email address');
		window.document.goorder.del_email.focus();
		return false;}
	if (document.goorder.del_email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.goorder.del_email.focus();
		return false;}
	if (document.goorder.del_email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		window.document.goorder.del_email.focus();
		return false;}
	return true;	
}
function Login(){
	if (document.Form1.email.value == ''){
		alert('Your email address has not been entered\nPlease enter your email address');
		document.Form1.email.focus();
		return false;}
	if (document.Form1.email.value.indexOf('@') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		document.Form1.email.focus();
		return false;}
	if (document.Form1.password.value == ""){
		alert('Please enter a password');
		document.Form1.password.focus();
		return false;}		
	return true;
}

function Forgot(){
	if (document.Form2.email.value.indexOf('.') == -1){
		alert('A valid email address has not been entered\nPlease enter a valid email address');
		document.Form2.email.focus();
		return false;}
	else
		return true;
}

// Validation on adding to cart
function ChkSelects(){
	if (window.document.product.colour != null) {
		if (window.document.product.colour.selectedIndex==0){
			alert('Option not selected, please choose option');
			window.document.product.colour.focus();
		return false;}
	}
	
	if(window.document.product.size != null) {
		if (window.document.product.size.selectedIndex==0){
			alert('Size not selected, please choose size');
			window.document.product.size.focus();
		return false;}
	}
	
	return true;
}

function ShowEmail(user, domain, anchor) {
	var OutText = '';
	OutText += '<a href="mailto:' + user + '@' + domain + '">';
	if (anchor != '') OutText += anchor;
	else OutText += user + '@' + domain;
	OutText  += '</a>';
	document.write(OutText);
}

///////////////////////////////////////////////////////////////
// Display 2 Decimal places Function
function DecTwo(amount) {
// returns the amount in the .99 format
    amount -= 0;
    return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}
// Rounding Function
function Round(number,X) {
// rounds number to X decimal places, defaults to 2
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

/*--------------TESTIMONIAL SCRIPT----------------*/
/*var i = 1;
var flag = true;

Effect.FadeIn = function(element) {
    element = $(element);
    new Effect.Appear(element, arguments[1] || {});
}

Effect.FadeOut = function(element) {
    element = $(element);
    new Effect.Fade(element, arguments[1] || {});
}

Effect.Fader = function(element) {
	element = $(element);
    if(element.style.display == 'none') {
    new Effect.FadeIn(element, arguments[1] || {}); }
    else { new Effect.FadeOut(element, arguments[1] || {}); }
	
	if(!flag)
	{
		flag = true
		i++;
		if (i == 4)
			i = 1;
	}
	else
	{
		flag = false;
	}

	setTimeout(function() { Effect.Fader('testimonal' + i); }, 4000);
	
}

setTimeout(function() { Effect.Fader('testimonal1'); }, 0);
*/

function externalLinks() { 

	if (!document.getElementsByTagName) return; 

	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		var relvalue = anchor.getAttribute("rel");

		if (anchor.getAttribute("href")) {
			var external = /external/;
			var relvalue = anchor.getAttribute("rel");
			if (external.test(relvalue)) { anchor.target = "_blank"; }
		} 
	}
} 
window.onload = externalLinks;