// JavaScript Document
function openwin(url, width, height){
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+ width +',height='+ height +',screenX=150,screenY=150,top=150,left=150')
}
function validate_booking(frm){
	
	if(frm.salutation.options[frm.salutation.selectedIndex].value==0){  
		alert('Please select salutation'); 
		frm.salutation.focus();
		return false;
	}
	if(frm.fname.value==0){  
		alert('Please enter First Name'); 
		frm.fname.focus();
		return false;
	}
	if(frm.lname.value==0){  
		alert('Please enter Last Name'); 
		frm.lname.focus();
		return false;
	}
	if(frm.birthday.value==0){  
		alert('Please select day of birth'); 
		frm.birthday.focus();
		return false;
	}
	if(frm.tel.value==0){  
		alert('Please enter Telephone'); 
		frm.tel.focus();
		return false;
	}
	/*if(frm.fax.value==0){  
		alert('Please enter Fax'); 
		frm.fax.focus();
		return false;
	}*/
	if(frm.email.value==0){  
		alert('Please enter email'); 
		frm.email.focus();
		return false;
	}else{
		if(!emailCheck(frm.email.value)){
			frm.email.focus()
			alert("Please enter a valid email");
			return false; 
		}
	}
	if(frm.request.value==0){  
		alert('Please enter Request'); 
		frm.request.focus();
		return false;
	}
	
	return true;
	
}
function check_newsletter(frm){
	if(frm.email.value==""){  
		alert('Please enter email'); 
		frm.email.focus();
		return false;
	}else{
		if(!emailCheck(frm.email.value)){
			frm.email.focus()
			alert("Please enter a valid email");
			return false; 
		}
	}
	return true;

}


function showsub(id, over){
idx = "m"+id;
identity=document.getElementById(idx);
	
	if(over == 0){
		
		document.getElementById(id).style.display='none';	
		
		this.className='';
	}else{
		
		document.getElementById(id).style.display='block';
		this.className='sub_sel';
	}
	
}
/*****************change opacity**************/

function opacity(id, opacStart, opacEnd, millisec) {
   	//speed for each frame
 	var speed = Math.round(millisec / 100);
   	var timer = 0;

   	//determine the direction for the blending, if start and end are the same nothing happens
   	if(opacStart > opacEnd) {
     		for(i = opacStart; i >= opacEnd; i--) {
     	    	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
     	       	timer++;
      	  	}
   		} else if(opacStart < opacEnd) {
        	for(i = opacStart; i <= opacEnd; i++)
            	{
            	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            	timer++;
        	}
   		}
	}


function changeOpac(opacity, id) {
	//change the opacity for different browsers
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

/*********************display banner ***********************************/
function jump(number, color_sel, color_norm){
		color_sel=color_sel?color_sel:'#cccccc'
		color_norm=color_norm?color_norm:'#ffffff'
		//jump to specific numbers
		clearTimeout(display);
		show=0; 
		hide=0;
		for(cnt=1; cnt<=count; cnt++){
			document.getElementById('banner'+cnt).style.display='none'
			document.getElementById('number'+cnt).style.color=color_norm
		}
		display_banner(number, color_sel, color_norm);
	}
	
	function display_banner(a, color_sel, color_norm, with_num){
		color_sel=color_sel ? color_sel : '#cccccc'
		color_norm=color_norm ? color_norm : '#ffffff'
		with_num=with_num ?  with_num : 0

	//display banners
		if(a<=count){
			//document.getElementById('number'+a).innerHTML=a
			if(show==1){
				if(hide==1){
					//hide picture
					document.getElementById('banner'+a).style.display='none'
					hide=0
					a++;
					show=0
					display_banner(a, color_sel, color_norm, with_num)
				}else{
					//change the opacity of the current picture to 0
					changeOpac(100, 'banner'+a)
					opacity('banner'+a, 100, 0, 500)
					hide=1
					if(with_num!=0){
						document.getElementById('number'+a).style.color=color_norm
					}
						display=setTimeout("display_banner("+a+", '"+color_sel+"', '"+color_norm+"',"+with_num+")", 500);
				}
			}else{
					//show picture
					show=1
					document.getElementById('banner'+a).style.display='block'
					if(with_num!=0){
						document.getElementById('number'+a).style.color=color_sel
					}
					changeOpac(0, 'banner'+a)
					opacity('banner'+a, 0, 100, 500)
					display=setTimeout("display_banner("+a+", '"+color_sel+"', '"+color_norm+"',"+with_num+")", 5000);
			}
		}else{
			//go back to start
			a=1
			show=0
			display_banner(a, color_sel, color_norm, with_num)
		}		
	} 
/*---------------------------- end display banner ---------------------*/

function submitform(frm){
	frm.submit();
}
function emailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
