﻿// JScript File

//show sub navigation layer
var last_tbl_sub_nav=null;
function show_sub_nav(tbl_sub_nav,state){
	if(state==1){//turn on
		tbl_sub_nav.style.display='block';		
		if((last_tbl_sub_nav!=null)&&(last_tbl_sub_nav!=tbl_sub_nav)){
			last_tbl_sub_nav.style.display='none';
		}
	last_tbl_sub_nav = tbl_sub_nav;
	}else{//turn off
		tbl_sub_nav.style.display='none';
	}
}
//hide the last dislpayed navigation layer
function hide_sub_nav(){
//alert("in");
	if(last_tbl_sub_nav!=null){
		last_tbl_sub_nav.style.display='none';
	}
}

var divider_prev_always_on="";//tab to keep on always
var divider_next_always_on="";//tab to keep on always
function tab_on(tab_id,state){
	var tab_index = tab_id.substring(4,tab_id.length);
	var divider_prev_id = 0;
	var divider_next_id = 0;
	//if tab is home tab
	if(tab_index=="home"){
		divider_prev_id="none";
		divider_next_id="divider_home";
	}else if((tab_index*1)>0){//if tab is a middle tab
	 divider_prev_id = "divider_" + ((tab_index*1)-1);
	 divider_next_id = "divider_" + tab_index;
	}else{//first tab after home
		divider_prev_id = "divider_home";
		divider_next_id = "divider_" + tab_index;
	}
	
	if(state=="on"){//turn tab on
		if(divider_prev_id!="none"){
			if(divider_next_always_on!=divider_prev_id){//if tab prev is not always on
				document.getElementById(divider_prev_id).className = "tab_divider_off_on";
			}else{//this tab is always on
				document.getElementById(divider_prev_id).className = "tab_divider_on_on";
			}
		}//not none
		//next divider
		if(divider_prev_always_on=="divider_-1"){
			divider_prev_always_on="divider_home";
		}
		if(divider_prev_always_on!=divider_next_id){//tab next is not always on
			if(tab_index!=4){//not last tab
				document.getElementById(divider_next_id).className = "tab_divider_on_off";
			}
			else{//last tab
				document.getElementById(divider_next_id).className = "tab_last_on";
			}
		}
		else{//tab next is always on
			document.getElementById(divider_next_id).className = "tab_divider_on_on";
		}
		//turn stretch off
		document.getElementById(tab_id).className = "tab_on";
	}
	else{//state off - turn tab off
		if(divider_prev_id!="none"){
			if(divider_next_always_on!=divider_prev_id){
				document.getElementById(divider_prev_id).className = "tab_divider_off_off";
			}
			else{
				document.getElementById(divider_prev_id).className = "tab_divider_on_off";
			}
		}//end not none
		if(tab_index!=4){//not last tab	
			if(divider_prev_always_on!=divider_next_id){
						
				document.getElementById(divider_next_id).className = "tab_divider_off_off";
			}else{
			document.getElementById(divider_next_id).className = "tab_divider_off_on";
			}
		}
		else{//last divider
			document.getElementById(divider_next_id).className = "tab_last_off";
		}
		//turn stretch off
		document.getElementById(tab_id).className = "tab_off";
	}
}
function link_popUp(psGuid)
{
	document.getElementById('PageConnectorForm1_HIH_pst_guid').value=psGuid;
	document.getElementById('PageConnectorForm1_HIH_root_channel').value='FirstGov';
	open_pop('');
	document.getElementById('popup_data').submit();
}
function setValue(currPage,cntrlID)
{	
	document.getElementById(cntrlID+"_TextBox1").value = currPage;
	var str = cntrlID + ':btnNav';
	__doPostBack(str,'')
}
function setValue2(currPage,cntrlID,paggingDirection)
{
	document.getElementById(cntrlID+"_TextBox1").value = currPage;
	var str = cntrlID + ':'+paggingDirection ;
	__doPostBack(str,'')
}
// function on: changes image to on 
function on(a,lang,id_name){
	if(id_name!=null){
		document.getElementById(id_name).src =  "/firstGov/images/"+ lang +"/" + a + "_on.gif";
	}else{
		document.getElementById(a).src =  "/firstGov/images/"+ lang +"/" + a + "_on.gif";
	}
	
	//document.images[a].src = "/firstGov/images/"+ lang +"/" + a + "_on.gif" ;
}
//function off: changes image to off
function off(a,lang,id_name){
	if(id_name!=null){
		document.getElementById(id_name).src =  "/firstGov/images/"+ lang +"/" + a + ".gif";
	}else{
		document.getElementById(a).src =  "/firstGov/images/"+ lang +"/" + a + ".gif";
	}
}
//confirm delete
function confirmDelete(sender,e,msg,pGuid,tbDel){
	if (confirm(msg))
	{
		document.getElementById(tbDel).value = pGuid;
		__doPostBack(sender,e);
	}
}

function redirectConfirmDelete(msg,deletePostingGuid){
	if (confirm(msg)){
		var curUrl = document.location.href;
		curUrl += "&deletePostingGuid="+deletePostingGuid;
		document.location.href=curUrl;
	}
	else {
		document.location.href="#";
	}
}
function redirectConfirmDeleteAll(msg,deletePostingGuid,strAll){
	if (confirm(msg)){
		var curUrl = document.location.href;
		curUrl +="&deletePostingGuid="+deletePostingGuid + "&strAll=" + strAll ;
		document.location.href=curUrl
	}
	else {
		document.location.href="#";
	}
}



function confirmCtrlDelete(ctrl,msg){
	if (ctrl != null){
		var delAction = ctrl.href.replace("javascript:","");
		if (confirm(msg)){	
			eval(delAction);			
		}
	}
}
function LinkItemListConfirmDelete(sender,e,message,PGuid,txtPindexID,txtGuidID,pIndex)
{
	if (confirm(message)){
	document.getElementById(txtPindexID).value = pIndex;
	document.getElementById(txtGuidID).value = PGuid;
	
	 __doPostBack(sender,e);
	}
}

function setPageHeight(screen_height){
	//if this element exists
	if(document.getElementById("tbl_page_height")){
	//set element minimum height according to screen height
		if(screen_height<=600){
			document.getElementById("tbl_page_height").style.height="290px";
		}else{
			document.getElementById("tbl_page_height").style.height="432px";
		}
	}
}
function resizeMe(x,y){
	//window.moveTo(screen.width/4,200);//screen.width,screen.height
	window.resizeTo(x,y);
}

function onSideMenu(cell){
	cell.className="right_menu_on";
}
function offSideMenu(cell){
	cell.className="right_menu";
}

// function buttOn: turns button on
function arrowOn(id,lang){

	 document.images[id].src = "/FirstGov/Images/" +lang + "/rightnav_main_butt-over.gif" ;
	 
}
// function buttOff: turns button off
function arrowOff(id,lang){
	 document.images[id].src = "/FirstGov/Images/" +lang + "/rightnav_main_butt.gif" ;
}

function left_item_iconOn(id,lang){
	 document.images[id].src = "/FirstGov/Images/" +lang + "/secon_level_icon-select.gif" ;
	
}
// function buttOff: turns button off
function left_item_iconOff(id,lang){
	 document.images[id].src = "/FirstGov/Images/" +lang + "/secon_level_icon.gif" ;
	
}



function openWin(url){ //open a pop up with a set size in top left corner
	window.open(url,'',"width=650 height=360 left=0 top=0 resizable scrollbars toolbar=no location=no");
}


function DoPostBack(ctrl){
	if(ctrl){
		if(ctrl.href!=""){
			var strHref = ctrl.href;
			strHref.replace("javascript:","");
			eval(strHref);
		}		
	}
}//end DoPostBack

function DoAlert(strAlert){
	alert(strAlert);
}
//function open  popup
//function openPop(name){
//urlName="/FirstGov/Micun/MofMicunTopNav/MofMicunAbout/MofMicunUnitStructure/" + name;
//var popWin=window.open(urlName,'name','width=400,height=200,top=400,left=200,toolbars=0');// open window
//popWin.focus();
//}

//function switchLangView - switch tabs in authoring mode btwn languages(default is hebrew)
var last_tab="heb";
var last_td_tab = null;
function switchLangView(lang,tab){
	document.getElementById(last_tab).style.display="none";
	if(last_td_tab==null){
		last_td_tab=document.getElementById("tab_heb");
	}
	last_td_tab.className="tab_off";
	document.getElementById(lang).style.display="inline";
	tab.className="tab_on";
	last_tab=lang;
	last_td_tab=tab;
}
function checkIfAcceptCoockies(failUrl)
{
	var allcoockies=document.cookie;
	if(allcoockies!=null)
	{
		return true;
	}
	else
	{
		location.href=failUrl;
		
		
	}
}
		
		
		
function outerItem(massage)
{
	alert(massage);
}

