var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var iePos = appVer.indexOf('msie');
if (iePos !=-1) {
is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
is_major = parseInt(is_minor);
}
var is_getElementById = (document.getElementById) ? "true" : "false";
var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
var is_documentElement = (document.documentElement) ? "true" : "false";
var is_ie = ((iePos!=-1));
var is_ie6 = (is_ie && is_major == 6);

var isIE=is_ie;

var PresedState="";
var State;
var xmlhttp = null;

function ChangeImg(N_Img,State){
			var myImg = N_Img;		
			var N_Img=document.getElementById(N_Img);	
			//alert(N_Img)			
			if(N_Img!=null){
				if (State==1)
				{		
					N_Img.src=N_Img.src.replace("_off","_on");				
				}
				else {											
					N_Img.src=N_Img.src.replace("_on","_off");
				}			
			}
		}
		


//DISPLAY THE BIG PICTURE IN THE IFRAME
function displayPic(objId,EN){
 PresedState="iiiiiiiiiiiii";
// alert(PresedState);
	//window.prompt('','gallery_pics.aspx?nsId=166&objId='+objId);
	//return false;
   if(EN =="True" ){
	   frames['picFrame'].location.href='gallery_pics.aspx?nsId=166&en=1&objId='+objId;
	}else{
		 frames['picFrame'].location.href='gallery_pics.aspx?nsId=166&objId='+objId;
	}

}	


 //alert(PresedState);
	
		

		
//BORDER FOR the gallrey small pics
function ChangePicBorder(PicId,BordrClr,selectState){
var presedPic="";

  if (presedPic!=PicId){
 // alert(presedPic);
    eval("document.all.pic_"+PicId+".style.border='"+BordrClr+"'");
   }

  
}


function openWindow(url,nme,prpt) {
 var sURL = url
 var sName = nme
 var sFeatures = prpt
 var wizWin = window.open(sURL, sName, sFeatures)
}



//DISPLAY THE THEN AND NOW PICTURES POPUP
function openPicPop(imgId,state)
	{
	    var wid="";
		var hit="";
		
		if (state=="h"){
		  wid=540;
		  hit=180;
		}
		else{
		  wid=420;
		  hit=270;
		}
		var url="";
		url = "then_and_now_pop.aspx?linkId=" + imgId +"&state=" + state;
		
		var WinSize= "";
		WinSize = "scrollbars=1, height=" + hit + "px , width=" + wid + "px ,top=150 ,left=150"
		
		window.open (url,"",WinSize)
	
	}


//OPENING A POP UP WITH THE REQUESTED IPIX (360 MOVIE)
 function openMovie(ipixId,lang) { 
    var movieId="video.aspx?MovID="+ ipixId + "&lang="+ lang;
    var sFeatures = "toolbar=no,width=690,height=363,left=80,top=180,directories=no,status=no,scrollbars=no,fullscreen=no,location=no,resizable=no,menubar=no,titlebar=yes";
     openWindow( movieId ,'videoPop', sFeatures);
 }
 
 
 
 //OPENING A POP UP WITH THE REQUESTED PANORMA (360 MOVIE)
 function openMovie1(panId,lang) { 
    var movieId="video1.aspx?MovID="+ panId + "&lang="+ lang;
    var sFeatures = "toolbar=no,width=620,height=383,left=80,top=180,directories=no,status=no,scrollbars=no,fullscreen=no,location=no,resizable=no,menubar=no,titlebar=yes";
     openWindow( movieId ,'videoPop', sFeatures);
 }



//DISPLAYING THE SUB CATEGORY FROM INDEX PAGE
function displaySub(SubId){
var subState

   subState=eval("document.all."+SubId+".style.display")
   if (subState=='none'){
     eval("document.all."+SubId+".style.display='inline'") 
   }
   else{
     eval("document.all."+SubId+".style.display='none'")
   }
}

//DISPLAY THE TOUR DESCRIPTION FOR EVERY ITEM (IN  TOUR_MAIN.ASPX)
function displayDesc(linkId,BoneId){
	if (typeof BoneId=="string")
		top.frames['desc'].location.href='tour_desc.aspx?boneID='+BoneId+'&objId='+linkId+"#title";   
    else
		top.frames['desc'].location.href='tour_desc.aspx?objId='+linkId+"&lng=en"+"#title"; 
	// alert('<%=English%>')
																
																
}	


//DISPLAY THE THEN AND NOW PICTURES
function displayThen(linkId){

   top.frames['link'].location.href='tour_desc.aspx?descId='+linkId;

}	


//display different pic(Then & Now)
		function disp1(id,picId)
			{
				var ObjDisplay = eval("tr"+id);
				
				for (i=1;i<4;i++){
					eval("tr"+i).style.display="none";
				}	
				ObjDisplay.style.display="block";
				document.all.pic.src='IMAGES/then_and_now/'+picId+'.jpg';
		}
		
		
//GLOBAL VAR FOR PICTURE HEADLINE
 var strPicHead="";
function disp1PP(picId,picDes){
   document.all.picDesc.innerHTML= "<strong>"+picDes+"</strong>"
   document.all.pic.src='IMAGES/then_and_now/'+picId+'.jpg';
   document.all.pic1.src='IMAGES/then_and_now/'+picId+'_n.jpg';
}

function hideSelectBox(){
    //hide selects to fix annoying select bug in ie
	if(isIE){
		var allSelects=document.getElementsByTagName("select");
		for(var x=0;x<allSelects.length;x++){		
			//if not in a modal box
			if(allSelects[x].className.indexOf('modal')==-1){
			    allSelects[x].style.visibility="hidden";	
			    }
		}
	}
}

function showSelectBox(){
    //show selects to fix annoying select bug in ie
	if(isIE){	
		var allSelects=document.getElementsByTagName("select");

		for(var x=0;x<allSelects.length;x++){
			allSelects[x].style.visibility="visible";	
		}
	}
}

//returns the rendered style of an element (as opposed to specified style)
function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

/* ********MODAL FUNCTIONS ******** */
function closeModal(id){
	if (isIE){
		showSelectBox();
	}
	document.getElementById("modalBackdrop").style.display="none";
	document.getElementById(id).style.display="none";
}

function showModal(id,e){
// alert(id);
    var modalBackdrop=document.getElementById('modalBackdrop');
	if (!modalBackdrop){
	    modalBackdrop=createModalBackdrop();
	}

	modalBackdrop.style.display="block";
	document.getElementById(id).style.display="block";
	countModalPosition(id,e);
/*	else{
		document.getElementById(id).style.left=countModalPosition(id,"left");
		document.getElementById(id).style.left=countModalPosition(id,"top");
	}
	*/

	if (isIE){
	    hideSelectBox();
		modalBackdrop.style.height=document.documentElement.scrollHeight+"px";
	}
}

function countModalPosition(id,e){
	var modalObj=document.getElementById(id);
	var modal_width_px=getStyle(document.getElementById(id+"_body"),"width");
	var indexof_px=modal_width_px.indexOf("px");
	var modal_width=modal_width_px.substring(0,indexof_px);
	var screen_width=screen.width;
	var leftPosition=(screen_width-modal_width)/2; 
	var objectHeight=modalObj.offsetHeight;
	//alert(objectHeight)

	modalObj.style.display='none';
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	modalObj.style.left=leftPosition+'px';
    if(!isIE) {
		posy = e.pageY;

        modalObj.style.top = (xClientHeight()/2-objectHeight/2+xScrollTop(window,true))+"px";
		//modalObj.style.top =(posy+ xScrollTop(window,true))/2+"px";
    }
    else {
        modalObj.style.top = (xClientHeight()/2-objectHeight/2+xScrollTop(window,true))+"px";
/*        posy = event.clientY;
		posy += document.body.scrollTop;
		if((posy/2 -objectHeight/2)<=50){
			var screen_h=screen.height;
			modalObj.style.top = screen_h/2 -objectHeight/2;
		}
		else{
			modalObj.style.top = posy/2 -objectHeight/2 +xScrollTop(window,true)+'px';
		}*/
    }
	modalObj.style.display='inline';
}

function xClientHeight()
{
  var v=0,d=document,w=window;
  if((!d.compatMode || d.compatMode == 'CSS1Compat') && !w.opera && d.documentElement && d.documentElement.clientHeight)
	{v=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
	{v=d.body.clientHeight;}
  else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
	v=w.innerHeight;
	if(d.width>w.innerWidth) v-=16;
  }
  return v;
}
function xScrollTop(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
	var w = window;
	if (bWin && e) w = e;
	if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
	else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
	e = xGetElementById(e);
	if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}
function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function createModalBackdrop(){
    modalBackdrop=document.createElement('div');
    modalBackdrop.id="modalBackdrop";
    modalBackdrop.style.display="none";
    document.body.appendChild(modalBackdrop);
    return modalBackdrop;
}
/* END MODAL FUNCTIONS */

/* AJAX Functions */
function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
/* print Functions */

function Print_popup_page(page_type, tag_id) {
//alert("print");
    var disp_setting = "location=no,toolbar=yes, directories=no,menubar=yes, scrollbars=yes, resizable=yes, width=700, height=580";
    var popup_window = window.open('print_content.asp?type='+ page_type + '&tagid=' + tag_id, 'modal_content' , disp_setting);
}
function Print_popup_en_page(page_type, tag_id) {
	var disp_setting = "location=no,toolbar=yes, directories=no,menubar=yes, scrollbars=yes, resizable=yes, width=700, height=580";
	var popup_window = window.open('print_en_content.asp?type='+ page_type + '&tagid=' + tag_id, 'modal_content' , disp_setting);
}

