/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

/*function ajaxchange(uid,pagina,subpagina,lang){
	var lang_back = window.document.mainMovie.GetVariable('_root.lang');
	window.document.mainMovie.SetVariable("_root.lang_back", lang_back);
	
	var pagina_back = window.document.mainMovie.GetVariable('_root.pagina');
	window.document.mainMovie.SetVariable("_root.pagina_back", pagina_back);
	
	var sezione_back = window.document.mainMovie.GetVariable('_root.sezione');
	window.document.mainMovie.SetVariable("_root.sezione_back", sezione_back);
	
	var contenuto_back = window.document.mainMovie.GetVariable('_root.contenuto');
	window.document.mainMovie.SetVariable("_root.contenuto_back", contenuto_back);
	
	window.document.mainMovie.SetVariable("_root.lang", lang);
	window.document.mainMovie.SetVariable("_root.pagina", pagina);
	window.document.mainMovie.SetVariable("_root.sezione", uid);
	window.document.mainMovie.SetVariable("_root.contenuto", subpagina);
}*/
function ajaxextra(extra){
	window.document.mainMovie.SetVariable("_root.extra", extra);
}
/*function in_array(pagina,arraydipagine){
			for(n in arraydipagine){
				if(arraydipagine[n] === pagina){
					return true;
				}
			}
			return false;
		}*/
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------

 //function ajaxpage(url, containerid, uid){
	function ajaxpage(pagina,content,fascia,id,idpagina,idcontent,lingua){
	//var pagine = new Array("index.php","entra.php");
	//if(in_array(pagina,pagine)){
		var page;
		page =  $.ajax({
			url: pagina,
			async: false
			}).responseText;
		$("#"+content).load(pagina);
		/*--------------------------*/
		if (fascia != undefined && fascia != null){
			$("#sinistra").load(fascia);
		}
		
		/*
		if(v != undefined && v != null){
        return true;
    }
    return false; 
		
		0,\'azienda\',\'presentazione\',\''.$lingua.'\'
		function ajaxchange(uid,pagina,subpagina,lang){
		*/
		window.document.mainMovie.SetVariable("_root.stato_pagina", "forward");
		
		var lang_back = window.document.mainMovie.GetVariable('_root.lang');
		window.document.mainMovie.SetVariable("_root.lang_back", lang_back);
		
		var pagina_back = window.document.mainMovie.GetVariable('_root.pagina');
		window.document.mainMovie.SetVariable("_root.pagina_back", pagina_back);
		
		var sezione_back = window.document.mainMovie.GetVariable('_root.sezione');
		window.document.mainMovie.SetVariable("_root.sezione_back", sezione_back);
		
		var contenuto_back = window.document.mainMovie.GetVariable('_root.contenuto');
		window.document.mainMovie.SetVariable("_root.contenuto_back", contenuto_back);
		
		window.document.mainMovie.SetVariable("_root.lang", lingua);
		window.document.mainMovie.SetVariable("_root.pagina", idpagina);
		window.document.mainMovie.SetVariable("_root.sezione", id);
		window.document.mainMovie.SetVariable("_root.contenuto", idcontent);
		
	//} else {*/
		//alert('Non Puoi.');
	}
function ajaxswf(pagina,content,popup,fascia,footer){
	var page;
		page =  $.ajax({
			url: pagina,
			async: false
			}).responseText;
		if (pagina != undefined && pagina != null){
			$("#"+content).load(pagina);
		}
		
		if (popup != undefined && popup != null){
			$("#popup").load(popup);
		}
		if (fascia != undefined && fascia != null){
			$("#sinistra").load(fascia);
		}
		if (footer != undefined && footer != null){
			$("#main_footer").load(footer);
		}
		//window.document.mainMovie.SetVariable("_root.stato_pagina", "back");
    }
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
/*function ajaxpage_OLD(url, containerid){
	//document.getElementById(containerid).innerHTML='';
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
		page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	if (bustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
	if (!document.getElementById)
		return
		for (i=0; i<arguments.length; i++){
			var file=arguments[i]
			var fileref=""
			if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
				if (file.indexOf(".js")!=-1){ //If object is a js file
					fileref=document.createElement('script')
					fileref.setAttribute("type","text/javascript");
					fileref.setAttribute("src", file);
				}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}*/

function changecolor(id, color) {
	element = document.getElementById(id);
	event.cancelBubble = true;
	oldcolor = element.currentStyle.background;
	element.style.background = color;
}
