﻿/* random images */
function randomImg() {
	if(document.getElementById("imageSplash") == null){
		var UrlStatic = "/int/en/SiteCollectionImages/";
		var exst = ".jpg";
		var randomNum = Math.floor(Math.random()*3) + 1;
		var img = UrlStatic + "testata_" + randomNum + exst;
		//document.getElementById("imgRan").style.display = "block";
		document.getElementById("imgRan").src = img ;
		}
}

var searchOn = true;
 
/* auto focus on tabs */
function checkTab(){

	if(document.getElementById("archTab")!=null)
	{
		if(document.getElementById("archTab").value!="0")
			showTab(document.getElementById("archTab").value);
		else
			showTab(comTab);
	}
	else
	{
		if(parent.ifr_comunicati){
		parent.ifr_comunicati.showTab(comTab);
		}
		if(parent.ifr_eventi){
		parent.ifr_eventi.showTab(comTab);
		}
		if(parent.iframe_sx){
		parent.iframe_sx.showTabEv(comTab);
		}
	
		if(document.getElementById("comInvMed") && searchOn) {
			showTab(comTab);
		}
	}
}

function showTab(divId)
{	
	searchOn = false;
	numTabs = 3;
	for ( i=1;i<=numTabs;i++)  {
		if( i == divId) {
			document.getElementById("eventi_" + divId).style.display = "block";
			document.getElementById("tabeventi_" + divId).className = "tabEventi_on";
			
		}
		else {
			document.getElementById("eventi_" + i).style.display = "none";
			document.getElementById("tabeventi_" + i).className = "tabEventi_off";
		}
	}
			
}



function showTabEv(divId)
{	
	numTabs = 4;
	for ( i=1;i<=numTabs;i++)  {
		if( i == divId) {
			document.getElementById("eventi_" + divId).style.display = "block";
			document.getElementById("tabeventi_" + divId).className = "tabEventi_on";
			
		}
		else {
			document.getElementById("eventi_" + i).style.display = "none";
			document.getElementById("tabeventi_" + i).className = "tabEventi_off";
		}
	}
			
}


//* NUOVA FUNZIONI PER LA COMMUTAZIONE PAGINA ITA ENG A LIVELLO DELL 'ITEM*/
function getXmllHttpRequest() {
                var obj;
                if (window.XMLHttpRequest) obj= new XMLHttpRequest(); 
                else if (window.ActiveXObject){
                               try{
                                               obj= new ActiveXObject('Msxml2.XMLHTTP');
                               }
                               catch(er){
                                               try{
                                                               obj= new ActiveXObject("Microsoft.XMLHTTP");
                                               }
                                               catch(er){
                                                               obj= false;
                                               }
                               }
                }
                return obj;
}
/* NUOVA FUNZIONI PER LA COMMUTAZIONE PAGINA ITA ENG A LIVELLO DELL 'ITEM*/
function pageExists(url) {
                var req= new getXmllHttpRequest(); // XMLHttpRequest object
                try {
                               req.open("HEAD", url, false);
                               req.send(null);                                
                               return req.status== 200 ? true : false;
                }
                catch (er) {
                               return false;
                }
}

/* NUOVA FUNZIONI PER LA COMMUTAZIONE PAGINA ITA ENG A LIVELLO HOME */

/*
function SetLanguage(lang)
{
var loc;
var curloc;
var oldloc=window.location.href.toLowerCase();
if(lang=="it")
{
loc="/";
}
else
{ 
curloc=oldloc.replace("/int/en","");
var host=curloc.indexOf("/",7);

loc=curloc.substr(0,host)+"/int/"+lang.toLowerCase() +"/"
}

document.location.href=loc;
window.location.replace(loc);
}

*/


function SetLanguage(lang)
{
	var loc;
	var oldloc=window.location.href.toLowerCase();
	if(lang=="it")
	{
		loc=oldloc.replace("/int/en","");
	}
	else
	{		
		var curloc=oldloc.replace("/int/en","");
		var host=curloc.indexOf("/",7);
		loc=curloc.substr(0,host)+"/int/"+lang.toLowerCase() +"/"+curloc.substr(host+1);
	}
	
	document.location.href=loc;
	window.location.replace(loc);
}






function FixFeatureButtons()
{
	var toolMail;
	var toolPrint;
	var toolPref;

	toolMail=document.getElementById("ico_alert");
	if(toolMail!=null)
		toolMail.href="mailto:?subject=Link to UGF site: "+window.document.title+"&body="+window.location.href;

	toolPrint=document.getElementById("ico_print");
	if(toolPrint!=null)
		toolPrint.href="javascript:window.print();";

	toolPref=document.getElementById("ico_pref");

	if(toolPref!=null)
	{	
		if (window.sidebar) { 
			toolPref.href="javascript:window.sidebar.addPanel('"+window.document.title+"', '"+window.location.href+"','')"; 
		} 
		else {
			toolPref.href="javascript:window.external.addfavorite('"+window.location.href+"','"+window.document.title+"');";
		}
	}
}

function FixJob()
{
	var curPath=document.getElementById("curPath");
	if(curPath.innerHTML.indexOf("Careers")>0)
	{
		var title=document.getElementById("spanMenuTitle"); //.innerText="Lavora con noi";
		title.innerHTML="Careers";
	}
}

function winPopup(page, left, top, width, height)
{
	var __wpopup = window.open(page, "__wpopup", "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height);
	__wpopup.focus();		
}

function expanfFaq(numFaq) {
 var head;
 var elem;
 var img;
 elem = document.getElementById("faqnum_" + numFaq);
 img = document.getElementById("faqimg_" + numFaq);
 row = document.getElementById("real_row_" + numFaq);
 //alert(numFaq + "--" + elem  + "--" + img + "--" + row);
if(elem.style.display == "none" || elem.style.display == "") {
 	elem.style.display = "block";
 	img.src = "/_layouts/images/minus.gif";
 	row.style.marginBottom = "20px";
 }
 else {
 	elem.style.display = "none";
 	img.src = "/_layouts/images/plus.gif";
 	row.style.marginBottom = "0px";

 }
 if(document.getElementById('box_arch'))
 	{ checkIfr('box_arch');}
 }



function checkIfr(label) {
	elem = document.getElementById(label);
	newH = elem.scrollHeight;
	parent.resizeIfr(newH);
}


function resizeIfr(setH) {
	ifr = document.getElementById("ifr_archdoc");
	ifr.style.height = setH + "px";
}


function GoToQuikLink(){
		var element = document.getElementById("quicklinkselect");
		var linkString = element.value;
			
		if ((linkString != '*') && (linkString.replace(/^ +/,"").length != 0)){
			var n = linkString.indexOf('|');
			
			var iLink = linkString.substring(0,n);
			var iTarget = linkString.substring(n+1);
			
			OpenNewWindow(iLink,iTarget);
			return false;
		}
	}
	
	function OpenNewWindow(url,iTarget){
		
		switch(iTarget){
			case '1':
				var target = "_blank";
				break;    
			case '0':
				var target = "_self";
				break;
			default:
				var target = "_blank";
		}
	
		window.open(url,target);
		//return false;
	}

	function ApriFormConcorso(){
		newWin = window.open('http://www.unipolgf.it/sites/concorso/_layouts/FormServer.aspx?XsnLocation=http://www.unipolgf.it/sites/concorso/Concorso/Forms/template.xsn&SaveLocation=http://www.unipolgf.it/sites/concorso/Concorso&Source=http://www.unipolgf.it/sites/concorso/Pagine/Default.aspx&DefaultItemOpen=1','finestraindipendente','scrollbars=yes,resizable=no,width=800,height=450,status=no,location=no,toolbar=no');
	}
