﻿// JScript File
var showbtns=false; // for showing the showgallery and showvideo buttons in tpl
var checkVideoGallery = true;
var checkMap=true;




function movedown(divid)
{
														
	var val = navigator.userAgent; 
	//if(val.indexOf("Firefox") != -1)
    //{										                
    //var t = document.getElementById(divid).style.top
    //alert(t + "value in movedown")
	//t= t.replace("px","")
	//t  = (eval(t) + eval(13)) + "px";
	//document.getElementById(divid).style.top = t;
	//}
}

function moveup(divid)
{
	var val = navigator.userAgent; 

//	if(val.indexOf("Firefox") != -1)
//		{  										                
//		   alert(t + "value in moveup")
//	var t = document.getElementById(divid).style.top
//	t= t.replace("px","")
//	t  = (eval(t) - eval(13)) + "px";
//	document.getElementById(divid).style.top = t;
//		 } 
	}



function addValue(dropdown,txtbox)
    {
        drpValue = document.getElementById(dropdown).value
        txt = document.getElementById(txtbox)
        if (txt.value != "") {
            txt.value= txt.value + "," + drpValue}
        else{
            txt.value = drpValue}
    }
    
function confirmDelete(cId,delId)
    {
        var x=window.confirm("Are you sure")
        if (x)
        {
        window.location.href="showPage.aspx?contentid=" + cId + "&delid=" + delId
        }
   }
   
function showDiv(typ)
   {
    displaynone()
    
    if (typ=="cat")
    {
    displayNoneDestination()
    //document.getElementById("imgCat").style.display="block";
    //document.getElementById("CatDesDiv").style.display="block";
    //document.getElementById("categorynote").style.display="block";
    }
    
    if (typ=="tc")
    {
    document.getElementById("imgTc").style.display="block";
    document.getElementById("tcMapDiv").style.display="block";
    document.getElementById("trailsnote").style.display="block";
    document.getElementById("imgtcMap").src="images/explore_dest_gujaratmap.gif";// + imgSrc +"_map.jpg";
    }
    
    if (typ=="des")
    {
        displayShowDestination()
        document.getElementById("imgDes").style.display="block";
        //document.getElementById("CatDesDiv").style.display="block";
        document.getElementById("destinationNote").style.display="block";
    }
    
   }
   
function displaynone()
{
     
     //document.getElementById("imgCat").style.display="none";
     //document.getElementById("imgDes").style.display="none";
     //document.getElementById("imgTc").style.display="none";
     //document.getElementById("categoryDiv").style.display="none";
     //document.getElementById("tcDiv").style.display="none";
     //document.getElementById("tcMapDiv").style.display="none";
     //document.getElementById("CatDesDiv").style.display="none";
     document.getElementById("categoryResultDiv").style.display="none";
     //document.getElementById("tcResultDiv").style.display="none";
     //document.getElementById("destinationNote").style.display="none";
     //document.getElementById("trailsnote").style.display="none";
     //document.getElementById("categorynote").style.display="none";

}

function displayNoneDestination()
{
 
   /* var destination = ["Palitana-Shatrunjaya","MarineNationalPark","Bhuj","Dholavira","Champaner-Pavagadh","Jamnagar","GirNationalPark","Ahmedabad","Vadodara","Patan","ModheraSunTemple","Surat","Rajkot","Lothal","Junagadh","Shamlaji","TarangaHills","Somnath","Ambaji","Dwarka","Dakor","VeravadarblackbuckNationalPark","WildAssSanctuary-LittleRann","NorthwestKutch","MandviBeach","VansdaNationalPark","PoloMonumentandVijaynagarForest","Vadnagar","NarmadaRiver","SaputaraHillStation"];
    for(i=0;i<=destination.length-1;i++)
	{
	    document.getElementById(destination[i]).style.display="none";
	}
	*/
}

function displayShowDestination()
{
 
    /*var destination = ["Palitana-Shatrunjaya","MarineNationalPark","Bhuj","Dholavira","Champaner-Pavagadh","Jamnagar","GirNationalPark","Ahmedabad","Vadodara","Patan","ModheraSunTemple","Surat","Rajkot","Lothal","Junagadh","Shamlaji","TarangaHills","Somnath","Ambaji","Dwarka","Dakor","VeravadarblackbuckNationalPark","WildAssSanctuary-LittleRann","NorthwestKutch","MandviBeach","VansdaNationalPark","PoloMonumentandVijaynagarForest","Vadnagar","NarmadaRiver","SaputaraHillStation"];
    for(i=0;i<=destination.length-1;i++)
	{
	     document.getElementById(destination[i]).style.display="block";
	}
	*/
}
   
   
   /*
how to use
http://localhost:3379/tcglcms/showpage.aspx?contentid=555&type=guide&location=137
window.gQueryString = new QueryString();
gQueryString.Read();
gQueryString.GetValue("type");
*/
function QueryString() {
	var data = [];
	this.Read = function() 
	{
		var aPairs, aTmp;
		var queryString = new String(window.location.search);
		queryString = queryString.substr(1, queryString.length); //remove "?"
		aPairs = queryString.split("&");	
		
		for (var i=0 ; i<aPairs.length; i++)
		{
			aTmp = aPairs[i].split("=");
			data[aTmp[0]] = aTmp[1];
		}
	}
	
	this.GetValue = function( key )
	{
		return data[key];
	}
	this.SetValue = function( key, value )
	{
		if (value == null)
			delete data[key];
		else 
			data[key] = value;
	}
	this.ToString = function()
	{
		var queryString = new String(""); 
		
		for (var key in data)
		{	
			if (queryString != "")
				queryString += "&"
			if (data[key])
				queryString += key + "=" + data[key];		
		}
		if (queryString.length > 0)
			return "?" + queryString;
		else
			return queryString;
	}
	this.Clear = function()
	{
		delete data;
		data = [];
	}
}

function rand(){
	var tem = Math.round(100000000000 - (50000000000 * Math.random(1)));
	return tem;	
}

function zoomimage(imagename,titles,img_description)
{

var img = new Image();
img.src = imagename;
widthf = img_description;
heightf = titles;
	
if(!widthf) widthf=img.width;
if(!heightf) heightf=img.height;
	
	widthf+=10;
	heightf+=20;
		
	if((!titles) && (img.height>heightf)) heightf=img.height+150;
	if((!img_description) && (img.width>widthf)) widthf=img.width+100;

	var noimage = false;
	if(img.height == 30 && img.width==28) noimage = true;

bgcol='#000000';
closefontcol='#FFFFFF';
t=100;
b=10;
desc_color="red";
height_increment="50";


	var tempmit = eval(rand().toString());
	var winstr='';
	if(imagename==''){alert("Please Provide Imagename");return;}
	if (titles!=''){winstr='<title>'+"TCGL"+'</title>';}else{winstr='<title>'+imagename+'</title>'}
	if (bgcol!=''){bgcolin=bgcol;}else{bgcolin='white';}
	winstr= winstr+'<body bgcolor='+bgcolin+'>';
	winstr= winstr+'<center><img id=img1 src='+imagename+'>';
	winstr= winstr+ '<br><font color='+desc_color+' face=verdana size=2>' +""+ '</font><br>' ;
	winstr= winstr+ '<a href=javascript:window.close();><font color='+closefontcol+' face=Arial size=2><b>Close</b></font></a>';
	winstr= winstr+ '</center></body>';
	//if no image is true then do not open window
	if(noimage==false)
	{
		tempmit = window.open('',eval(rand().toString()),'width=400,height=300,scrollbars=0,resizable=0');
		tempmit.document.writeln(winstr);
		tempmit.moveTo((screen.width-400)/2,(screen.height-300)/2);
	}
}


function handleEnter(e)
{
	var characterCode;
	if(e && e.which)
	{
		e = e;
		characterCode = e.which;
	} 
	else 
	{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13)
	{
		window.location.href='showpage.aspx?contentid=985&query='+document.getElementById('txtsearch').value;
		//window.location.href='searchpage.aspx?cx=004080986754821053065%3Aeu-tdkcvjuq&cof=FORID%3A11&ie=UTF-8&q='+document.getElementById('txtsearch').value+'&sa=Search';
		return false;
	} 
	else
	{
		return true;
	}
}

//var contentid=0;
//var tempX = 0;
//var tempY = 0;
//var IE;



//function showRevision(cid) {
////alert(cid)
//contentid = cid;
//IE = document.all?true:false;

//if (!IE) document.captureEvents(Event.MOUSEUP)
////document.onclick = getMouseXY;
//if (contentid != 0 )
//    {
//        document.getElementById(cid).onmouseup = getMouseXY;
//    }
//}

//function getMouseXY(e) 
//{
//    if (contentid != 0)
//    {
//        if (IE) 
//        { // grab the x-y pos.s if browser is IE
//        tempX =  event.clientX; //document.documentElement.scrollLeft;
//        tempY = event.clientY + document.documentElement.scrollTop;
//        }
//        else {  // grab the x-y pos.s if browser is NS
//        tempX = e.pageX;
//        tempY = e.pageY;
//        }
//    if (tempX < 0){tempX = 0;}
//    if (tempY < 0){tempY = 0;}
//    document.getElementById("showR").style.left=tempX + "px";
//    document.getElementById("showR").style.top=tempY + "px";
//    document.getElementById("showR").style.display="block";
//    }
//    else
//    {
//      document.getElementById("showR").style.display="none";    
//    }
//   
////contentid=0;
//return true;
//}

function opengallerywindow(url,wid,hgt)
{
    var WUrl = url;
    var WWid = wid;
    var Wht = hgt;
    var features = "width=" + WWid + ",height=" + Wht + ",status=No,menubar=No,toolbar=no,scrollbar=no,resizable=yes";
    galleryWindow = window.open (WUrl, "gwindow",features);
    galleryWindow.moveTo(0,0);
}

function showDestinationPage(drpid)//drpID)
{
    var url = "showpage.aspx?contentid="
    var contentId = document.getElementById(drpid).value;
    url = url + contentId
    window.location.href = url;
}

function galleryshow(showwhat)
{

    document.getElementById("ctl02_PhotoGalleryCtl1_webpartvideo").style.display="none";
    document.getElementById("ctl02_PhotoGalleryCtl1_wphotogallery").style.display="none";
    if (showwhat=="ctl02_PhotoGalleryCtl1_webpartvideo")
    {
        setTable('pichander',2);
    }
    else
    {
        setTable('pichander',3);
    }
    document.getElementById(showwhat).style.display="block";
}

function setTable(id,status)
{
    try
    {
        var td1 = document.getElementById("pichander");
        if (td1 != "undefined")
        {
            if (status==1)
            {
                td1.style.display="none";
            }
            else if (status==2)
            {
                td1.style.backgroundImage="url()";
            }
            else
            {
                td1.style.backgroundImage="url(images/bg_map.jpg)";
            }
        }
    }
    catch(err)
    {
     /*   txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        txt+="Click OK to continue.\n\n";
        alert(txt);*/
    }
    
}
function gsearch()
{
	window.location.href='showpage.aspx?contentid=985&query='+document.getElementById('txtsearch').value;
	//window.location.href='searchpage.aspx?cx=004080986754821053065%3Aeu-tdkcvjuq&cof=FORID%3A11&ie=UTF-8&q='+document.getElementById('txtsearch').value+'&sa=Search';
}

function addQuery()
{
    var o = document.links;
    var qstr;
    var query = "&lang=" +  document.getElementById("hidLang").value;
        for(var i=0;i<o.length;i++)
        {
            qstr =o[i].href;
            if (qstr.indexOf('#divhub') != -1)
            {  
                qstr = qstr.replace('#divhub','');
                o[i].href = qstr+query+'#divhub';
            }
            else if (qstr.indexOf('#0') != -1)
            {  
                qstr = qstr.replace('#0','');
                o[i].href = qstr+'#0';
            }
			else if (qstr.indexOf('&lang=') != -1)
            {
                o[i].href = o[i].href;
            }
            else if (qstr.indexOf('showpage.aspx') != -1)
            {
                o[i].href = o[i].href+query;
            }
			
        }
}

function showpage(cid,webpartid)
{
    
    var query = "&lang=" +  document.getElementById("hidLang").value;
    var contid = cid;
    if (contid.indexOf('#divhub') != -1)
    {  
        contid = contid.replace('#divhub','');
        query = query + '#divhub';
    }
    
    var showUrl = "showpage.aspx?contentid=" + contid;
    
    if(webpartid!=null)
    {
        showUrl = showUrl + "&webpartid=" + webpartid;
    }
    showUrl = showUrl + query;
    window.location.href=showUrl;
}

function showLanguage(lng)
{
    var query = "&lang=" + lng;
    var sUrl;
    var mainUrl = window.location.href;
   
    if (mainUrl.indexOf('#divhub') != -1)
       {  
            query = query + '#divhub';
       }
       
    if (mainUrl.indexOf('&lang=') != -1)
    {
        mainUrl = mainUrl.substring(0,mainUrl.indexOf("&lang"))
    }
    
    if (mainUrl.indexOf('showpage.aspx') != -1)
    {
        window.location.href=mainUrl+query;
    }
    else
    {
        window.location.href=mainUrl + "showpage.aspx?" + query;
    }
}