function change_image(image,width,height,id)
{
	document.getElementById(id).src="../images/"+image;
	document.getElementById(id).width=width;
	document.getElementById(id).height=height;
}
function swap_image(image,width,height,id)
{
	document.getElementById(id).src="images/"+image;
	document.getElementById(id).width=width;
	document.getElementById(id).height=height;
}



function disable()
{
	//alert("ji");
	if(document.frmf.trip[0].checked==true)
	{
	document.frmf.inbound_date.disabled=true;
	document.frmf.inbound_time.disabled=true;
	}
	else if(document.frmf.trip[1].checked==true)//(document.frm.trip[1].selected==true)
	{
	document.frmf.inbound_date.disabled=false;
	document.frmf.inbound_time.disabled=false;
	}
	
	

}
function show()
{
	if(!document.frm.check.checked)
	{
		document.getElementById('drop1').style.display="";
		document.getElementById('drop2').style.display="";
	}
	else
	{
		document.getElementById('drop1').style.display="none";
		document.getElementById('drop2').style.display="none";
		
	}
}

function change_form()
{
	URLvar=document.URL;
	values=URLvar.split('?');
	if(document.frm.type[0].checked)
	{
		window.location='form.php';
	}
	if(document.frm.type[1].checked)
	{
			window.location='cars.php';
	}
	if(document.frm.type[2].checked)
	{
		window.location='hotels.php';
		
	}	
}
function recomend_check()
{	
	if(document.frm.recomend[1].checked)
	{
		document.frm.friend_email.disabled=true;
		document.frm.friend_email.style.background="white";	
	}
	else
	{
		document.frm.friend_email.disabled=false;
	}
}
function sendemail(fromemail,toemail)
{	//alert(fromemail);
	var getstr ='fromemail='+encodeURI(fromemail)+'toemail='+encodeURI(toemail)+'&sid='+Math.random();
	//alert(getstr)	
	ajaxpack.getAjaxRequest("madue/tellafriend.php", getstr, get_status, "txt", '')
}
function get_status()
{
	var myajax = ajaxpack.ajaxobj;
	var myfiletype = ajaxpack.filetype;
	var products_page = ajaxpack.callback_parameter;
	if (myajax.readyState == 4)
	{
		//if request of file completed
		if (myfiletype=="txt")
		{
			alert(myajax.responseText);
			document.getElementById('fromemail').value="";
			document.getElementById('toemail').value="";
		}
	}
}
function checkfield()
{		
	if(document.getElementById('fromemail').value=="")
	{
		alert("Please enter your email");
		document.getElementById('fromemail').focus();
		return false;
	}
	if(document.getElementById('toemail').value=="")
	{
		alert("please enter your freind's email");
		document.getElementById('toemail').focus();
		return false;
	}
	return validate_form2(document.getElementById('toemail').name);
}
function validate_form2(toemail)
{
	if (validate_email2(toemail,"Not a valid e-mail address!")==false)
  	{
		document.getElementById('toemail').focus();
		return false;
	}
	else
	{
		sendemail(document.getElementById('fromemail').value,document.getElementById('toemail').value);
	}
}
function validate_email2(field,alerttxt)
{
	apos=document.getElementById(field).value.indexOf("@");
	dotpos=document.getElementById(field).value.lastIndexOf(".");
	if (apos<1||dotpos-apos<2) 
	{
		alert(alerttxt);
		return false;
	}
	else 
	{
		return true;
	}	
}

function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
  		{
  			alert(alerttxt);
  			return false;
  		}
		else 
		{
			return true;
		}
	}
	
}
function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
  		{
  			email.focus();
  			return false;
  		}
		document.frmf.action="reservation-details.php";
		document.frmf.submit();
	}	
}
function resident_check()
{
	if(!document.frm.resident.checked)
	{
		//document.frm.country.style.visibility="visible";
		document.frm.country.style.display="";
	}
	else
	{
		//document.frm.country.style.visibility="hidden";
		document.frm.country.style.display="none";
	}
}
function checklogin()
{
	if(document.form1.agency.value=="")
	{
		alert("Username can not be blank.");
		document.form1.agency.focus();
		return false;
	}
	if(document.form1.password.value=="")
	{
		alert("Password can not be blank.");
		document.form1.password.focus();
		return false;
	}
	
}



