function get_sid(){
    var sid = window.location.search;
    sid = sid.substr(5, 24);
    //alert(sid);
    
    return sid;
}

function getInitParam(name){
	var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == name) {
      return pair[1];
    }
  } 
  return null;	
}

function openPopUpWindow(v_strPage, v_strWidth, v_strHeight){
	window.open(v_strPage, "smatPopUpWin","dependent=yes,Height=" + v_strHeight + ",Width=" + v_strWidth + ", top=0, left=0, location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,linksbar=no");
}

function openPopUpWindow2(v_strPage, v_strWinName, v_strWidth, v_strHeight){
	window.open(v_strPage, v_strWinName,"dependent=yes,Height=" + v_strHeight + ",Width=" + v_strWidth + ", top=0, left=0, location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,linksbar=no");
}

function voidFunction(){
	//ie bug
}

function OpenPrintWindow(v_strURLPrint){
	var oWin = window.open(v_strURLPrint,'','status=no,scrollbars=yes,width=550px,height=450px,resizable=yes');
	//oWin.focus();
	//oWin.print();
}

function LoadDataToPrint(){
	var strId = 'tabToPrint';
	var objSource = window.opener.document.getElementById(strId);
	var objDest = window.document.getElementById(strId);
	objDest.innerHTML = objSource.innerHTML;
	window.print();
	//alert(objSource.innerHTML)
}

function LoadDataToPrintSMAT(){
	var strId = 'contentToPrint';
	var objSource = window.opener.document.getElementById(strId);
	var objDest = window.document.getElementById(strId);
	objDest.innerHTML = objSource.innerHTML;
	window.print();
	//alert(objSource.innerHTML)
}

function OpenPrintWindowSMAT(v_strURLPrint){
    if(window.name!='PrintSmat'){
	    var oWin = window.open(v_strURLPrint,'PrintSmat','status=no,scrollbars=yes,width=550px,height=450px,resizable=yes');
    }else{
        window.print();
    }	
}


function createFlash(src){
    if (navigator.appVersion.indexOf("MSIE") != -1){
    var strContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" ';
    //se non sono definiti width e height ==> non li setto
    strContent += 'width="726" ';
    strContent += 'height="328">';
    strContent += '<param name="movie" value="'+src+'">';
    strContent += '<param name=quality value=high>';
    strContent += '<param name="wmode" value="window">';
    strContent += 'Flash plug-in not installed.';
    strContent += '</object>';
    document.write(strContent);
  }else{
	document.write('<object type="application/x-shockwave-flash" data="'+ src +'" width="726" height="328" wmode="transparent">Flash plug-in not installed.</object>');
  }
}


function createFlashOL(src){
    if (navigator.appVersion.indexOf("MSIE") != -1){
    var strContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" ';
    //se non sono definiti width e height ==> non li setto
    strContent += 'width="998" ';
    strContent += 'height="100%">';
    strContent += '<param name="movie" value="'+src+'">';

    strContent += '<PARAM NAME=bgcolor VALUE=#FFFFFF>'

    strContent += '<param name=quality value=high>';
    strContent += '<param name="wmode" value="window">';
    strContent += 'Flash plug-in not installed.';
    strContent += '</object>';
    document.write(strContent);
  }else{
	document.write('<object type="application/x-shockwave-flash" data="'+ src +'" width="998" height="100%" wmode="window">Flash plug-in not installed.</object>');
  }
}

function credits(){
	window.open("credits.htm","credits","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=140");
}

function getObject(v_strIdImage){
	var vObj;
	
	var strBrowserName = whatbrowser();
	
	switch(strBrowserName){
		case "NN6":
		case "NN4":{
			vObj = document.getElementById(v_strIdImage);
			break;
		}
		case "ie4":
		case "ie6":
		case "ieMac":{
			vObj = document.all(v_strIdImage);
			break;
		}
		default:{
			vObj = document.all(v_strIdImage);
		}
	}
	
	return(vObj);
}


//whatbrowser()
//
//determina con quale browser l'utente è collegato e restituisce la sigla corrispondente
//
//argomenti:
//	nessuno
//
//valore di ritorno:
//	stringa	=	sigla corrispondente al browser con cui l'utente è collegato
//				NN4	=	netscape4
//				NN6	=	netscape6
//				ie	=	internet explorer
function whatbrowser(){
	var thisbrowser = "";	//sigla del browser utilizzato dall'utente
	var strAppVersion = navigator.appVersion;

	var blnIsIe4 = (strAppVersion.indexOf("MSIE 4") == -1) ? 0 : 1;
	var blnIsIe5 = (strAppVersion.indexOf("MSIE 5") == -1) ? 0 : 1;
	var blnIsIe6 = (strAppVersion.indexOf("MSIE 6") == -1) ? 0 : 1;
	var blnIsMac = (strAppVersion.indexOf("Macintosh") == -1) ? 0 : 1;
	
	//interrogo l'oggetto document per capire quale broeser sta utilizzando l'utente
    if(document.layers){
        thisbrowser="NN4";
    }
    if(document.all){
         if(blnIsIe4 == 1 || blnIsIe5==1) thisbrowser="ie4";
         else if(blnIsIe6 == 1) thisbrowser="ie6";
         else if(blnIsMac == 1) thisbrowser="ieMac";
         else thisbrowser="ie";
         
         //alert(thisbrowser);
    }
    if(!document.all && document.getElementById){
         thisbrowser="NN6";
    }
    
    return(thisbrowser);
}

//npwidthmax()
//
//calcola width della pagina, toglie larghezza menu sinistra e larghezza menu 
//destra return (la differenza)
function npwidthmax(){
	size = parseInt(window.innerWidth) - 161;
	return size;
}


function MM_preloadImages() {
	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 OpenZoomWindow(sImg,sTitle,sWidth,sHeight){
	var oWin = window.open('','','status=0,scrollbars=0,height='+(sHeight/1+17)+'px,width='+sWidth+'px');
	var sHtml = '<html>\n';
	sHtml += '<head><title>' + sTitle + '</title>\n';
	sHtml += '<style type=\"text/css\">\n';
	sHtml += '.fntDefault { text-decoration: none; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #514C3C }\n';
	sHtml += '</style>\n</head>\n';
	sHtml += '<body bgcolor=\"#ffffff\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n';
	sHtml += '<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n';
	sHtml += '<tr><td align=\"center\" valign=\"middle\"><img border=\"0\" src=\"'+sImg+'\"  alt=\"'+sImg+'\"></td></tr>\n';
	sHtml += '<tr height=\"2\"><td bgcolor=\"#EBEAE5\"><img src=\"img/shared/np.gif\" height=\"2\" alt=\"\"></td></tr>\n';
	sHtml += '<tr height=\"15\"><td bgcolor=\"#F8F7F1\" align=\"right\" valign=\"middle\" class=\"fntDefault\"><a class=\"fntDefault\" href=\"javascript:window.close()\">close</a>&nbsp;&nbsp;</td></tr>\n';
	sHtml += '</table>\n';
	sHtml += '</body>\n';
	sHtml += '</html>';
	oWin.document.write(sHtml);
}

function OpenZoom(sImg,sTitle){
	var oWin =  window.open(''+ sImg +'','','status=0,scrollbars=0,height=50px,width=50px');
}

function createMedia(mediaType,src,width,height,bgcolor,wmode,swliveConn,embedMovie){
    //si tratta di flash
    if (mediaType == 0){
		if (navigator.appVersion.indexOf("MSIE") != -1){
			var strContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" ';
			//se non sono definiti width e height ==> non li setto
			if (width != "") strContent += 'width="' + width + '" ';
			if (height != "") strContent += 'height="' + height + '"';
			strContent += '>';
			strContent += '<param name="movie" value="'+src+'">';
			strContent += '<param name="quality" value="high">';
			strContent += '<param name="bgcolor" value="'+bgcolor+'" />';
			strContent += '<param name="wmode" value="'+wmode+'">';
			
			if (swliveConn != "") strContent += '<param name="SwLiveConnect" value="'+swliveConn+'">';
			if (embedMovie != "") strContent += '<param name="EmbedMovie" value="'+embedMovie+'">';
			
			strContent += 'Flash plug-in not installed.';
			strContent += '</object>';
			document.write(strContent);
		}else{
			document.write('<object type="application/x-shockwave-flash" data="'+src+'" ');
			
			//se non sono definiti width e height ==> non li setto
			if (width != "") document.write('width="'+width+'" ');
			if (height != "") document.write('height="'+height+'" ');
			
			document.write('wmode="'+wmode+'" bgcolor="'+bgcolor+'" ');
			
			if (swliveConn != "") document.write('SwLiveConnect="'+swliveConn+'" ');
			if (embedMovie != "") document.write('EmbedMovie="'+embedMovie+'"');
			
			document.write('>Flash plug-in not installed.</object>');
		}
	}
}

//crea un iframe nascosto per conversioni google!
function ga_conversion(page) {

    var iframe = document.createElement('iframe');
    
    iframe.style.width = '0px';
    iframe.style.height = '0px'; 
    
    document.body.appendChild(iframe); 
    
    iframe.src = 'ga_conversions/'+page;
}
