// JavaScript Document



// ------------------ MENU INFO ------------------------------------------

//var rootpath = "http://www.inspire-geoportal.eu/geoportal/";

var rootpath = "";



// 3 columns : 1. file name, 2. section name, 3. root path for links, 

var menuArray = new Array(5,3); 



menuArray[0] = Array("index.htm", "home", rootpath);
menuArray[1] = Array("infotours.htm", "info tours", rootpath);
//menuArray[2] = Array("communities/client/", "communities", rootpath);
menuArray[2] = Array("catalogues.htm", "catalogues", rootpath);
menuArray[3] = Array("inspireEditor.htm", "metadata editor",rootpath);
menuArray[4] = Array("maps.htm", "maps",rootpath);


//*********Site stats analysis functions*******

//insert scripts for stats!!

function insertstatcode(){

/*

statstring = "<a href=\"http://www.phpmyvisites.us/\" title=\"Free web analytics, website statistics\" onclick=\"window.open(this.href);return(false);\"><script type=\"text/javascript\"> var a_vars = Array(); var pagename=''; var phpmyvisitesSite = 1; var phpmyvisitesURL = \"http://test-lmu.h07.jrc.it/phpmv2/phpmyvisites.php\"; </script> <script language=\"javascript\" src=\"http://test-lmu.h07.jrc.it/phpmv2/phpmyvisites.js\" type=\"text/javascript\"></script> <object><noscript><p>Free web analytics, website statistics <img src=\"http://test-lmu.h07.jrc.it/phpmv2/phpmyvisites.php\" alt=\"Statistics\" style=\"border:0\" /></p></noscript></object></a>";



document.write(statstring);

*/

//alert(document.body.innerHTML);

};

	

//----------------



function drawmenu(mysectionname){



	

//--Previous system based on URL--	

//var pagename = location.pathname;

//splitres = pagename.split("/");

//ubound = splitres.length-1;

//pagename = splitres[ubound];

//alert (pagename);





//alert (menuArray[1][2]);

for (i=0; i<menuArray.length ;i++){

	filename = menuArray[i][0];

	sectionname = menuArray[i][1];

	myhref = menuArray[i][2];

	

	classdef = ""; // variable used to give a different style to the tab correspondig to the current page

	if (sectionname == mysectionname){

		classdef = "class=\"selected\"";

		};

	

	document.write("<li><a href=\""+myhref+filename+"\"><span "+classdef+">"+sectionname+"</span></a></li>");

	};

};



function setwherestring(mysectionname){



var URLparam = document.location.search;

//alert (URLparam);



for (i=0; i<menuArray.length ;i++){

	filename = menuArray[i][0];

	sectionname = menuArray[i][1];

	myhref = menuArray[i][2];



	if (sectionname == mysectionname){

		document.write("&nbsp;<a href=\"http://www.ec.europa.eu\">European Commission</a> / ");

		document.write("<a href=\""+rootpath+"\">INSPIRE GEOPORTAL</a> / ");

		document.write("<a href=\""+myhref+filename+"\">"+sectionname+"</a>");

		

		if (!(URLparam == "")){

        //alert (URLparam);

		splitURLparam =  URLparam.split("=");

		ubound = splitURLparam.length - 1;

		lastparamvalue = splitURLparam[ubound];

		document.write(" / <a href=\"#\">"+lastparamvalue+"</a>");

		};

		

	 };

	

	

};

};



function launchWindow(url, features) {

  window.open(url, "_blank", features);

}



/*

function entryboxhover(){

	this.bgColor = "#cc0000";

	alert(this.bgColor);

	};



function entryboxout(){

	this.bgColor = "#eeeeee";

	}; */
//Hong_start
function getWindowSize()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{

			w = document.documentElement.clientWidth;
			//IE return and a bigger size, so it must be substracted 83px
			h = document.documentElement.clientHeight  - 83;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

//var viewerUrl = "http://d01ri0301288.h07.jrc.it:8080/INSPIREViewServiceClient/mapclienttemplate/index.html";
//var viewerUrl = "http://www.inspire-geoportal.eu/INSPIREViewServiceClient/mapclienttemplate/index.html";
function setViewerUrlToCMS () {
	var viewerUrl = document.getElementById("viewerUrl").value;
	var currentURL = window.location.search;

	if (currentURL)	 {
	var queryString = decodeURI(window.location.search);
//	var Hong = currentURL.pathname;
	var urlArray = queryString.split("viewerId=");
	//var urlArray = currentURL.split("pageid");
	viewerUrl = urlArray[1];

	var t1 =1;	
	}

	document.getElementById("mainx").src=viewerUrl;
	resizeIframe();
}	
//window.onload=setViewerUrlToCMS;	

function resizeIframe() {
//var h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
var h = getWindowSize().height;
//alert(window.size.height);
//alert(h);
//var newH = h-120;
//var newH = h-45;
//document.getElementById("mainx").height=(newH);
//default
var newH = h - 60;

if (window.ActiveXObject) {
  if(screen.height > 1023){
    newH = h-45;
  }
  else {
   newH = h-60;
  }
}
else { 
  if(screen.height > 1023){
    newH = h-130;   
  }
  else {
   newH = h-95;  
  }
}

document.getElementById("mainx").height=(newH);
//alert(screen.height);
//alert(h);
//document.getElementById("mainx").width='100%';


}
	
//Hong_end
