// JavaScript Document
function ratingStar(mod,till){
	for(a=0; a<=4; a++){
		//alert(mod+'|'+a);
	document.getElementById(mod+'|'+a).src='images/star_bg.gif';
	}
	
	for(a=0; a<=till-1; a++){
		//alert(mod+'|'+a);
	document.getElementById(mod+'|'+a).src='images/star.gif';
	}

}

function changePict(limit,vid) {
if(vid>0 && limit>=0){
$('imgs').innerHTML='<center><img src="images/loading.gif"><br>loading...</center>';
	var url 	= 'ajax.php';
	var params = 'mod=1&vid='+vid+'&from='+limit;
//document.write(params);
	var myAjax = new Ajax.Request(url, {method: 'get', parameters: params, onComplete: status_message});
}
}
function status_message(a){
if(a.responseText!= ""){
$("imgs").innerHTML=a.responseText;
}
}
function loadCals(vid,year) {
if(vid>0){
$('cals').innerHTML='<center><img src="images/loading.gif"><br>loading...</center>';
	var url 	= 'ajax.php';
	var params = 'mod=2&vid='+vid+'&year='+year;
//document.write(params);
	var myAjax = new Ajax.Request(url, {method: 'get', parameters: params, onComplete: changeCals});
}
}
function changeCals(a){
if(a.responseText!= ""){
$("cals").innerHTML=a.responseText;
}
}

function showHide(mod){
	if(mod==1){
		$('sdesc').style.display='none';
		$('ldesc').style.display='';
	}
	else if(mod==2){
		$('sdesc').style.display='';
		$('ldesc').style.display='none';

	}
}

function onRateClick(rating,question_id)
{
	var params = 'pid=1&question_id='+ question_id +'&rating='+ rating +'&rnd='+Math.random();
	//document.write(params);
	var url 	= 'ajax.php';
	var myAjax = new Ajax.Updater('ratings_'+question_id,url, {method: 'get', parameters: params});
}

function RateAnsClick(rate,answer_id,question_id)
{
	var params = 'pid=2&question_id='+ question_id +'&answer_id='+ answer_id +'&rate='+ rate +'&rnd='+Math.random();
	//document.write(params);
	var url 	= 'ajax.php';
	var myAjax = new Ajax.Updater('ans_rate_'+answer_id,url, {method: 'get', parameters: params});
}




function checkAvailablity(frm){
	arrival_date 	= frm.arrival_date.value;
	departure_date	= frm.departure_date.value;
	no_of_travelrs	= frm.no_of_travelrs.value;
	vid = frm.vid.value;
	if(arrival_date == ""){
		alert("Please Select Arrival Date");
	return false;
	}
	if(departure_date == ""){
		alert("Please Select Departure Date");
	return false;
	}
	if(vid>0){
		//$('cals').innerHTML='<center><img src="images/loading.gif"><br>loading...</center>';
			var url 	= 'ajax.php';
			var params = 'mod=3&vid=' + vid + '&arrival_date='+ arrival_date + '&departure_date='+departure_date + '&no_of_travelrs='+no_of_travelrs;
		//document.write(params);
			var myAjax = new Ajax.Request(url, {method: 'get', parameters: params, onComplete: showPrice});
	}
}

function showPrice(a){
	if(a.responseText!= ""){
	$("pricing").innerHTML=a.responseText;
	}
}

function show_tbl(id,hrefid){
			document.getElementById(id).style.display = "";
			var coma = ",";
			var cote = "'";
			var val = cote+id+cote+coma+cote+hrefid+cote;
			document.getElementById(hrefid).href = "javascript:; hide_tbl("+val+")";
}

function hide_tbl(id,hrefid){
		document.getElementById(id).style.display = "none";
		var coma = ",";
		var cote = "'";
		var val = cote+id+cote+coma+cote+hrefid+cote;
		document.getElementById(hrefid).href = "javascript:; show_tbl("+val+")";
}

function showPreview(img) {
	window.open(URL+"preview.php?id="+img,"popup","scrollbars=yes,location=0,directories=0,menubar=0,status=0,width=400,height=400,resize=yes");
}

function showpdf(id) {
	window.open(URL+"genpdf.php?id="+id,"popup","scrollbars=yes,location=0,directories=0,menubar=0,status=0,width=800,height=600,resizeable=yes");
}

function check_date(frm){
	if($('from_date').value==''){
		alert('Please select Arrival Date');	
		$('from_date').focus();
		return false;
	}
	
	if($('to_date').value==''){
		alert('Please select Departure Date');	
		$('to_date').focus();
		return false;
	}
	
	return true;
}

function submitask(){
			if(!window.confirm('Are you sure? you want to navigate to another page? \n\n You have not submit your question yet. \n\n Press ok to continue or Cancel to stay on the current page.'))
			   return false;
			 else{
				document.form2.submit();
			}

}

function show_ask(){
		Element.hide('askc');	
		Element.show('askq');	
	}

