/***********************************************
* Form fields Validation Script
***********************************************/

function ValidateForm(f){

      with(f){
         if (isEmpty(_1_Name.value)) {
            alert("Please enter your Name");
            _1_Name.focus();
            return false;
         }

         if (isEmpty(_2_Email_From.value)) {
            alert("Please enter your Email Address");
            _2_Email_From.focus();
            return false;
         }

         if ( !isEmail(_2_Email_From.value) ) {
            alert("Please enter a valid Email Address.");
            _2_Email_From.focus();
            return false;
         }

         if (!isEmpty(_3_Phone.value)) {
	         if (!IsNumber(_3_Phone.value, true)) {
            	alert("Please enter only numbers for your Phone");
            	_3_Phone.focus();
            	return false;
         	}
         }
         if (!isEmpty(_4_Fax.value)) {
         if (!IsNumber(_4_Fax.value, true)) {
            	alert("Please enter only numbers for your Fax");
            	_4_Fax.focus();
            	return false;
         	}
         }
         if (isEmpty(_5_Enquiries.value)) {
            alert("Please enter your Enquiry");
            _5_Enquiries.focus();
            return false;
         }
   	}
   return true;
 }


/***********************************************
* Calling external link instead of target="_blank"
***********************************************/


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;



/***********************************************
* Popup Pic Script
***********************************************/

function PopupPic() {
 if (arguments[1] == null || arguments[1].length == 0 || arguments[2] == null || arguments[2].length == 0) {
  window.open( "popup.asp?" + arguments[0], "", "resizable=1,HEIGHT=200,WIDTH=200"); 
 }
 else {
  window.open( "popup.asp?" + arguments[0], "", "resizable=1,HEIGHT=" + arguments[2] + ",WIDTH=" + arguments[1] + ""); 
 }
} 


/***********************************************
* Popup URL Script
***********************************************/


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/***********************************************
* ShowHide Script
***********************************************/

//Handle hiding or showing the current id
function ShowOrHideTable(sTheID,iStep) {

	if ( document.getElementById(sTheID).style.display == "block" )  {
		document.getElementById(sTheID).style.display = "none";
	}
	else {
		HideAll("caption_");
		document.getElementById(sTheID).style.display = "block";
	}
}

function HideAll(sPrefix) {

	var oTags = document.getElementsByTagName("*");
	var iPrefixLength = sPrefix.length;

	//Loop through the entire document looking at each tag
	for (var i = 0; i < oTags.length; i++) {
		//If the current tag supports having an ID, continue
		if ( oTags[i].id ) {
			//If the current tag has an ID, continue
			if ( oTags[i].id.length > iPrefixLength ) {
				//Check to see if the current ID is prefixed with what we are trying to hide
				if ( oTags[i].id.substring(0,iPrefixLength) == sPrefix ) {
					document.getElementById(oTags[i].id).style.display = "none";
				}
			}
		}
	}
}


/***********************************************
* Image Swap Script
***********************************************/

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];}
}

MM_preloadImages('images/gallery/1.jpg','images/gallery/2.jpg','images/gallery/3.jpg','images/gallery/4.jpg','images/gallery/5.jpg','images/gallery/6.jpg','images/gallery/7.jpg','images/gallery/8.jpg','images/gallery/9.jpg','images/gallery/10.jpg','images/gallery/11.jpg','images/gallery/12.jpg')

