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 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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function printpage( )
{
window.print( )
}

pic_width=400;   /*change to match the height of all your images */
pic_height=120;   /* change to match the width of all your images */
border_size=0;   /* change to the border size you want on the images */
alignment=1;      /* 0=left,1=center */

if (alignment==1) 
{ 
cent_it="<CENTER>"; 
cent_it2="<\/CENTER>"; 
} 
else 
{ 
cent_it=""; 
cent_it2=""; 
} 

function get_random(maxNum) 
{ 
if (Math.random && Math.round) 
{ 
var ranNum= Math.round(Math.random()*(maxNum-1)); 
ranNum+=1; 
return ranNum; 
} 
else 
{ 
today= new Date(); 
hours= today.getHours(); 
mins= today.getMinutes(); 
secn= today.getSeconds(); 
if (hours==19) 
hours=18; 
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1; 
return ranNum; 
} 
} 

function get_Image(which) 
{ 
if (document.images) 
{ 
if (which==1) 
{ 
var choose_one= get_random(29); 
choose_one--; 
var pics= new Array(29) 
   pics[0]="http://www.uncoverthecape.co.za/images/capetown1.jpg"
   pics[1]="http://www.uncoverthecape.co.za/images/capetown2.jpg"
   pics[2]="http://www.uncoverthecape.co.za/images/capetown3.jpg"
   pics[3]="http://www.uncoverthecape.co.za/images/capetown4.jpg"
   pics[4]="http://www.uncoverthecape.co.za/images/capetown5.jpg" 
   pics[5]="http://www.uncoverthecape.co.za/images/capetown6.jpg"
   pics[6]="http://www.uncoverthecape.co.za/images/capetown7.jpg"
   pics[7]="http://www.uncoverthecape.co.za/images/capetown8.jpg"
   pics[8]="http://www.uncoverthecape.co.za/images/capetown9.jpg"
   pics[9]="http://www.uncoverthecape.co.za/images/capetown10.jpg"
   pics[10]="http://www.uncoverthecape.co.za/images/capetown11.jpg"
   pics[11]="http://www.uncoverthecape.co.za/images/capetown12.jpg"
   pics[12]="http://www.uncoverthecape.co.za/images/capetown13.jpg"
   pics[13]="http://www.uncoverthecape.co.za/images/capetown14.jpg"
   pics[14]="http://www.uncoverthecape.co.za/images/capetown15.jpg"
   pics[15]="http://www.uncoverthecape.co.za/images/capetown16.jpg"
   pics[16]="http://www.uncoverthecape.co.za/images/capetown17.jpg"
   pics[17]="http://www.uncoverthecape.co.za/images/capetown18.jpg"
   pics[18]="http://www.uncoverthecape.co.za/images/capetown19.jpg"
   pics[19]="http://www.uncoverthecape.co.za/images/capetown20.jpg"
   pics[20]="http://www.uncoverthecape.co.za/images/capetown21.jpg"
   pics[21]="http://www.uncoverthecape.co.za/images/capetown22.jpg"
   pics[22]="http://www.uncoverthecape.co.za/images/capetown23.jpg"
   pics[23]="http://www.uncoverthecape.co.za/images/capetown24.jpg"
   pics[24]="http://www.uncoverthecape.co.za/images/capetown25.jpg"
   pics[25]="http://www.uncoverthecape.co.za/images/capetown26.jpg"
   pics[26]="http://www.uncoverthecape.co.za/images/capetown27.jpg"
   pics[27]="http://www.uncoverthecape.co.za/images/capetown28.jpg"
   pics[28]="http://www.uncoverthecape.co.za/images/capetown29.jpg"

document.write(cent_it+"<IMG SRC='"+pics[choose_one]+"' width='"+pic_width+"' height='"+pic_height+"' border='"+border_size+"'>"+cent_it2); 
}
} 
} 

var newwindow;
function popwindow(url)
{
	newwindow=window.open(url,'name','width=540,height=267,top=0,left=0');
	if (window.focus) {newwindow.focus()}
}

function checkform()
	{
		var strAlert = new String()

		if (document.forms[0].Name.value == 0)
		{
			strAlert = strAlert + 'Please enter your Name.\n'
		}

		if ((document.forms[0].Enquiry.value == ''))
		{
			strAlert = strAlert + 'Please enter your Enquiry or Reservation.\n'
		}
		
		if (document.forms[0].Email.value == 0)
		{
			strAlert = strAlert + 'Please enter your Email Address.\n'
		}
		else
		{
			var x = document.forms[0].Email.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x) == false)
			{
				Email = document.forms[0].elements[1].id
				Email = Email.substr(0,1)
				strAlert = strAlert + 'Please provide a valid E-Mail Address.\n' 	
			}
		}
		
		if (strAlert == '')
		{
			document.forms[0].submit();
		}
		else
		{
			alert(strAlert)
			
		}
	}


function checknews()
	{
		var strAlert = new String()

		if (document.forms[0].person.value == 0)
		{
			strAlert = strAlert + 'Please enter your Name.\n'
		}
		
		if (document.forms[0].mail.value == 0)
		{
			strAlert = strAlert + 'Please enter your Email Address.\n'
		}
		else
		{
			var x = document.forms[0].mail.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x) == false)
			{
				mail = document.forms[0].elements[1].id
				mail = mail.substr(0,1)
				strAlert = strAlert + 'Please provide a valid E-Mail Address.\n' 	
			}
		}
		
		if (strAlert == '')
		{
			document.forms[0].submit();
		}
		else
		{
			alert(strAlert)
			
		}
	}	
