

function archiveResult(divCount,thisDiv){
	
	for(i = 1; i<=divCount; i++){
		
		document.getElementById('pollArchive_'+i).style.display = 'none';
		}
	document.getElementById('pollArchive_'+thisDiv).style.display = 'block';
}

function callPage(pageNum){
		
		document.forms.pagingForm.page.value = pageNum;
		document.forms.pagingForm.submit();
	}
	
function show(id,fld){
		hide();
		document.getElementById(id).style.display = 'block';
		document.getElementById(fld).className = 'tabActive';
	}
	
function hide(){
	
	document.getElementById('personalInformation').style.display = 'none';
	document.getElementById('piTab').className = 'tabInActive';
	document.getElementById('Application').style.display = 'none';
	document.getElementById('aTab').className = 'tabInActive';
	document.getElementById('skillNexp').style.display = 'none';
	document.getElementById('seTab').className = 'tabInActive';
	document.getElementById('references').style.display = 'none';
	document.getElementById('rTab').className = 'tabInActive';
	}

function fsDisplay(r){
	var res = eval("(" + r + ')');
	$("#fsQueryStringDiv").html(res.query_string);
	$("#fsQueryStringDiv").show();
	
	if(res.response_bit == '-1'){
		$("#resultTable").hide();
		$("#time_zone").hide();
		$("#fsResultBody").html("");
		$("#fsNoResultOnDateDiv").hide();
		$("#fsNoFlightOnDateDiv").hide();
		$("#fsNoResultDiv").show();
		
	}else if(res.response_bit == '-2'){
		$("#resultTable").hide();
		$("#time_zone").hide();
		$("#fsResultBody").html("");
		$("#fsNoResultOnDateDiv").show();
		$("#fsNoFlightOnDateDiv").hide();
		$("#fsNoResultDiv").hide();
	}else if(res.response_bit == '-3'){
		$("#fsNoResultDiv").hide();
		$("#fsNoResultOnDateDiv").hide();
		$("#nfod_date").html(res.query_date);
		$("#fsNoFlightOnDateDiv").show();
		$("#fsResultBody").html(res.response_text);
		$("#resultTable").show();
		$("#time_zone").show();
	}else{
		$("#fsNoResultDiv").hide();
		$("#fsNoResultOnDateDiv").hide();
		$("#fsNoFlightOnDateDiv").hide();
		$("#fsResultBody").html(res.response_text);
		$("#resultTable").show();
		$("#time_zone").show();
		}		
	}

function fetchFlightSearchResults(path,comb){
	var mvType = $("#movementType").val();
	var al = $("#airline").val();
	var flno = $("#flightNumber").val();
	var dt = $("#date").val();
	if(dt == "تاريخ") { var dt1 = "";  }else { var dt1 = dt;} 
	var ap = $("#airport").val();
	var url = path+"flightSearchResult.php";
	
	$.post(url,
  		{ movementType: mvType, airline: al, flightNumber: flno, date: dt1, combination:comb, airport:ap},
  			function(response){
    		//$("div#flightSearchResults").html(response);
			fsDisplay(response);
  		}
	);
}

function fetchFlightSearchResultsPage(path,mvType,al,flno,dt,page,comb,ap){
	
	var url = path+"flightSearchResult.php";
	if(dt == "تاريخ") { var dt1 = "";  }else { var dt1 = dt;} 
	$.post(url,
  		{ movementType: mvType, airline: al, flightNumber: flno, date: dt1, thisPage: page, combination:comb,airport:ap},
  			function(response){
    		//$("div#flightSearchResults").html(response);
			fsDisplay(response);
  		}
	);
}


function adjustDiv(){
	var left = $("#bodyContentsLeft").height();
	var right = $("#bodyContentsRight").height();
	//alert(left + "  " +right);
	if(right > left){ $("#bodyContentsLeft").css({'min-height': right+"px"}); } 
	else { $("#bodyContentsRight").css({'min-height': left+"px"}); } 
}


function showSuggestionsDiv (){
	for(i=2;i<=6;i++){
		$("#contents-"+i).slideToggle();	
	}
	adjustDiv();
}

function showSubSubMenu(value){
	$(value).slideToggle("fast", adjustDiv);
}

function totalView_increment(tn, rid)
{
	if(rid != 0){
		var url="php-totalViews-increment.php";
		$.get("url", { action: "increment", tableName: tn, recordID: rid, sid: Math.random() } );	
	}
}

function showHideDiv(value){
   $(value).slideToggle("slow");
}


function scrollTo(selector) {
    var targetOffset = $(selector).offset().top;
    $('html,body').animate({scrollTop: targetOffset}, 1500);
}


$(document).ready(function(){
	$.ifixpng(baseWebsiteURL+'graphics/shim.gif');
 	$('img[@src$=.png]').ifixpng();
	adjustDiv();

	//setTimeout(adjustDiv(), 5000);
});

