var tab = "street";
var cat = "";
var idcity = "";
var idpoi = "";
var idroute = "";


$(function() {
	$("#categorySelect").sexyCombo({filterFn: function() {
        return true;
    }});
});


function loadCategory()
{
	$("#categorySelect").sexyCombo({filterFn: function() {
        return true;
    }});
}

function changeStreetTap()
{
	tab ="street";
	var className = $('#menu_streetSearch').attr('class');
	if(className == "item")
	{
	  $('#menu_streetSearch').removeClass('item');
	  $('#menu_streetSearch').addClass('item selected');
	  
	  $('#menu_landmarkSearch').removeClass('item  selected');
	  $('#menu_landmarkSearch').addClass('item');
	  
	  $('#menu_About').removeClass('item  selected');
	  $('#menu_About').addClass('item');
	  
	  document.getElementById("toolbarStreetSearch").style.display = "block";
	 document.getElementById("toolbarLandmarkSearch").style.display = "none";
	 document.getElementById("toolbarAbout").style.display = "none";
	 
	 /* var d = document.getElementById("filterDiv");
	  d.innerHTML = '<input id="filterText" class="txtSearch"  type="text" onkeyup="filterEdit(this)" title="Find Street" onclick="return filterText_onclick()">   <a id="filterClearLink" href="javascript:filterClear()" style=" font-size:20px; color:white;background-color:gray;padding:0px 5px 0px 5px;text-decoration:none;" title="Clear">X</a>';*/
	  
	  document.getElementById("streetSearch").style.display = "block";
	  document.getElementById("landmarkSearch").style.display = "none";
	  document.getElementById("legalDisclaimer").style.display = "none";
	 /* var e = document.getElementById("indexFrame");
	  e.innerHTML =  '<div id="indexDiv" style="font-size:10px;"><center><br /><br /><img src="images/mapload.gif" width="128" height="15" alt="loading" /></center></div><div id="resultDiv" style="width:100%;height:360px;overflow:auto;font-size:10px;display:none"></div>';*/
	  //location.reload();
	  location.href ="#?tab="+tab+cat+idroute+idcity+idpoi;
	}
	
}

function changeLandmarkTap()
{
	tab ="landmark";
	var className = $('#menu_landmarkSearch').attr('class');

	if(className == "item")
	{
	 

	  $('#menu_landmarkSearch').removeClass('item');
	  $('#menu_landmarkSearch').addClass('item selected');
	 
	 $('#menu_streetSearch').removeClass('item selected');
	 $('#menu_streetSearch').addClass('item');
	 
	 $('#menu_About').removeClass('item  selected');
	 $('#menu_About').addClass('item');
	  
	 document.getElementById("toolbarStreetSearch").style.display = "none";
	 document.getElementById("toolbarLandmarkSearch").style.display = "block";
	 document.getElementById("toolbarAbout").style.display = "none";
	 
	/* var d = document.getElementById("filterDiv");
	  d.innerHTML =  '<select id="categorySelect" onchange="categorySelectChange(this);" name="filter-combo__sexyCombo"><option selected="selected" value="city"">Cities</option><option value="poi">POI</option><option value="about">About</option></select>';
	  loadCategory();*/
	  document.getElementById("streetSearch").style.display = "none";
	  document.getElementById("landmarkSearch").style.display = "block";
	  document.getElementById("cityIndexDiv").style.display = "block";
	  document.getElementById("poiIndexDiv").style.display = "none";
	  document.getElementById("aboutDiv").style.display = "none";
	  document.getElementById("legalDisclaimer").style.display = "none";
	 /* var e = document.getElementById("indexFrame");
	  e.innerHTML =  '<div id="poiIndexDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="cityIndexDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="placeResultDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="aboutDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"><div style="padding:4px"><h3>About The Map</h3>Switzerland Video Street Views and POI.</div></div>';*/
		//location.reload();
		location.href ="#?tab="+tab+cat+idroute+idcity+idpoi;
	}
	
}

function changeAbout()
{
	tab ="about";
	var className = $('#menu_About').attr('class');

	if(className == "item")
	{
	  $('#menu_About').removeClass('item');
	  $('#menu_About').addClass('item selected');
	 
	 $('#menu_streetSearch').removeClass('item selected');
	 $('#menu_streetSearch').addClass('item');
	 
	 $('#menu_landmarkSearch').removeClass('item  selected');
	 $('#menu_landmarkSearch').addClass('item');
	  
	 document.getElementById("toolbarStreetSearch").style.display = "none";
	 document.getElementById("toolbarLandmarkSearch").style.display = "none";
	 document.getElementById("toolbarAbout").style.display = "block";
	 
	/* var d = document.getElementById("filterDiv");
	  d.innerHTML =  '<select id="categorySelect" onchange="categorySelectChange(this);" name="filter-combo__sexyCombo"><option selected="selected" value="city"">Cities</option><option value="poi">POI</option><option value="about">About</option></select>';
	  loadCategory();*/
	  document.getElementById("streetSearch").style.display = "none";
	  document.getElementById("landmarkSearch").style.display = "block";
	  document.getElementById("cityIndexDiv").style.display = "none";
	  document.getElementById("poiIndexDiv").style.display = "none";
	  document.getElementById("aboutDiv").style.display = "block";
	  document.getElementById("legalDisclaimer").style.display = "none";
	 /* var e = document.getElementById("indexFrame");
	  e.innerHTML =  '<div id="poiIndexDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="cityIndexDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="placeResultDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"></div><div id="aboutDiv" style="width:100%;height:360px;overflow:auto;display:none;font-size:10px"><div style="padding:4px"><h3>About The Map</h3>Switzerland Video Street Views and POI.</div></div>';*/
		//location.reload();
		location.href ="#?tab="+tab+cat+idroute+idpoi;
	}
}

function querySt(ji) 
{
	
	hu = window.location.href.substring(window.location.href.lastIndexOf("#?")+2);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
    {
		ft = gy[i].split("=");
		if (ft[0] == ji)
    	{
			return ft[1];
		}
	}
	
}

function queryStT(ji) 
{
	
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
    {
		ft = gy[i].split("=");
		if (ft[0] == ji)
    	{
			return ft[1];
		}
	}
	
}

function checkBookMark()
{
	t = (queryStT('t') != null)?queryStT('t'):"";
	tab = (querySt('tab') != null)?querySt('tab'):"";
	cat =(querySt("cat")!= null)?("&cat="+querySt("cat")):"";
	idcity = (querySt("idcity")!= null)?("&idcity="+querySt("idcity")):"";
	idpoi = (querySt("idpoi")!= null)?("&idpoi="+querySt("idpoi")):"";
	idroute = (querySt("idroute")!= null)?("&idroute="+querySt("idroute")):"";
	
	if(t != "")
	{
		StrTempT = location.href;
		StrTempT = StrTempT.replace("?t="+t+"&", "")
		location.href=StrTempT;
		//alert(t+"---"+StrTempT);
	}
	if(tab != "")
	{
		
		if(tab == "street")
		{
			
			changeStreetTap();
			
				
			if(idpoi != "")
				placeClick(querySt("idpoi"));
			if(idcity != "")
				cityClick(querySt("idcity"));
			if(idroute != "")
				routeClick(querySt("idroute"));
				
		}
		else if(tab == "landmark")
		{
			changeLandmarkTap();
			if(cat != "")
			{
				
				
				//categorySelectChange(querySt("cat"));
				if(querySt("cat") == "city")
				{
					document.getElementById("categorySelect").options[0].selected = true;
					
					if(idpoi != "")
						placeClick(querySt("idpoi"));
					if(idcity != "")
						cityClick(querySt("idcity"));
					if(idroute != "")
						routeClick(querySt("idroute"));
				}else if(querySt("cat") == "poi")
				{
					document.getElementById("categorySelect").options[1].selected = true;
					
					if(idcity != "")
						cityClick(querySt("idcity"));
					if(idpoi != "")
						placeClick(querySt("idpoi"));
					if(idroute != "")
						routeClick(querySt("idroute"));
				}
				
			}
		}
		else if(tab == "about")
		{
			changeAbout();
		}
	}
	
	
}


function selectEmbed()
{
	document.getElementById("inputEmbedCode").focus();
	document.getElementById("inputEmbedCode").select();
}
function  legalDislaimer()
{
	document.getElementById("legalDisclaimer").style.display = "block";
	document.getElementById("aboutDiv").style.display = "none";
	window.open("http://www.globalvision360.com/en/legal-disclaimer.html", "_blank");
}
function  aboutStreetview()
{
	document.getElementById("legalDisclaimer").style.display = "none";
	document.getElementById("aboutDiv").style.display = "block";
}
function fbs_click() 
{
	//var domain = temp.substring(0,mydomain.length + 1);
	var domain = location.href.substring(0,31);
	var addMore = "?t="+Math.random()*10+"&";
	//var therest = location.href.substring(31,location.href.length+1);
	//alert("a"+domain+"a---a"+addMore+"a-----a"+therest+"a")
	var tabfb ="#?tab="+querySt("tab");
	var idpoifb ="&idpoi="+querySt("idpoi");
	var catfb ="&cat="+querySt("cat");
	u=domain+addMore+tabfb+catfb+idpoifb;
	//alert(u);
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}


function twitter_click(titlePara) 
{
	//alert(titlePara);
	titlePara += " ";
	//var domain = temp.substring(0,mydomain.length + 1);
	var domain = "http://www.videostreetview.com";
	
	//var therest = location.href.substring(31,location.href.length+1);
	//alert("a"+domain+"a---a"+addMore+"a-----a"+therest+"a")
	var tabfb ="?tab="+querySt("tab");

	var idpoifb ="&idpoi="+querySt("idpoi");
	var catfb ="&cat="+querySt("cat");
	var idroute ="&idroute="+querySt("idroute");
	var u=domain+tabfb+catfb+idpoifb+idroute;

	//var u="http://streetview.ch?tab=landmark&cat=city&idpoi=13";
	//alert(u);
	//var title=document.getElementById("titlePanorama").innerHTML;
	//var t=document.title +"---"+ title.substring(0,(title.length - 118)) ;
	//alert("http://twitter.com/home?status="+encodeURIComponent(titlePara)+encodeURIComponent(u));
	//document.title =t;
	window.open('http://twitter.com/home?status='+encodeURIComponent(titlePara)+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
	//document.title ="StreetView Switzerland - Look as if you were there!";
	
}






