// browser detection
var BV=parseInt(navigator.appVersion.indexOf("MSIE")>0?navigator.appVersion.split(";")[1].substr(6):navigator.appVersion);
var BN=window.navigator.appName;
var IsWin=(navigator.userAgent.indexOf('Windows')!=-1)?true:false;
var OP=(navigator.userAgent.indexOf('Opera')!=-1&&BV>=4)?true:false;
var NS=(BN.indexOf('Netscape')!=-1&&(BV==4)&&!OP)?true:false;
var SM=(BN.indexOf('Netscape')!=-1&&(BV>=5)||OP)?true:false;
var IE=(BN.indexOf('Explorer')!=-1&&(BV>=4)||SM)?true:false;

// preload images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//screen resolution 
function myscreen(){
if(window.screen){
		if (screen.availWidth < 900){
			a= "800";
		}else if (screen.availWidth < 1100){
			a= "1024";
		}else {a= "";}
	return a ;
	}
}

//win popup
function popWin( url, name, width, height, scroller ) {
	var outStr = 'height=' + height + ',width=' + width;
	if (scroller == true) {	outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes';} 
	else if (scroller == false) {	outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';} 
	else {	outStr = outStr +',menubar=yes,toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes';
	}newWindow=window.open(url, name, outStr);
}

//Width and Height inside 
function InWidthHeight() {
		if(IE & !SM)
			return [document.body.clientWidth,document.body.clientHeight];
		if(NS||SM)
			return [window.innerWidth,window.innerHeight];
}	

//X,Y position of images
function GetImgXY(imgName) {
		var x;
		var y;	
		if(IE||OP)	{
			//return [document.images[imgName].offsetLeft ,document.images[imgName].offsetTop];
			x = getOffset(document.images[imgName])[0];
			y = getOffset(document.images[imgName])[1];		
		} else	{
			return [window.document.images[imgName].x,window.document.images[imgName].y];			
		}
		return [x, y];
		                   }
//X,Y position of images corretto per IE						   					
function getOffset(img) {
		x = img.offsetLeft;
		y = eval(img).offsetTop;
		ce = eval(img).offsetParent;
		while (ce!=null)	{
			y += ce.offsetTop;
			x += ce.offsetLeft;
			ce = ce.offsetParent;
		}
		return [x,y];
			
		}

/*
 * Tabs Menu (mouseover)- By Dynamic Drive
 * For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
 * This credit MUST stay intact for use
*/
	var submenu=new Array();
	var delay_hide=500;
			
	function showit(which, what){
		clear_delayhide()
		if (what!="no")thisPage(what);		
		thecontent=(which==-1)? "" : submenu[which]
		if (document.getElementById||document.all){
			menuobj.innerHTML=thecontent;
			if (what=="no")thisPage(what);
		}else if (document.layers){
			menuobj.document.write(thecontent)
			menuobj.document.close()
			if (what=="no")thisPage(what);
		}		
	}
	
	function resetit(e){
		if (document.all&&!menuobj.contains(e.toElement))
		delayhide=setTimeout("showit(-1, 'hide')",delay_hide)
		else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhide=setTimeout("showit(-1, 'hide')",delay_hide)
	}
	
	function clear_delayhide(){
		if (window.delayhide)
			clearTimeout(delayhide)
	}
	
	function contains_ns6(a, b) {
		while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
			return false;
	}
	

//hmenu css modification
function thisPage(num) {
 	if (!document.getElementById){
 		return true;
 	}
	if (num!="no"){ 
		var list = document.getElementById("mainNav");
		var page = list.getElementsByTagName("a");
		for (var i=0; i<page.length; i++){	
			page[i].style.borderBottom = "10px solid #6cbd34"; 
			}
		if(num!='hide'){
			page[num].style.borderBottom = "10px solid #3f8c65";
			}	
	}else{
		var list = document.getElementById("describe");
		var page = list.getElementsByTagName("a");
		for (var i=0; i<page.length; i++){			
			page[i].style.color = "#000000"; 
			}
	}
}

function xGetElementById(e)
{	
  if(typeof(e)=='string') {			
    if(document.getElementById) e=document.getElementById(e);
    else if(document.all) e=document.all[e];
    else e=null;
  }
  return e;
}
