/********************************************************************************
 
Name:     Flash plugin detect
 
*********************************************************************************/
var flash = new Object();	
flash.installed = false;
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {		
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {		
			flash.installed = true;					
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {		
				flash.installed = true;	
				flash.version = x;
			}
		}
		catch(e) {}
	}
}

/* from prototype */
function unescapeHTML(str) {
   try {
     var div = document.createElement('div');
     div.innerHTML = str.replace(/<\/?[^>]+>/gi, '');
     return div.childNodes[0].nodeValue;
   } catch (e) {
     return str;  // sometimes it goes wrong, like when str is empty.
   }
}

function escapeHTMLforFRT(str) {
	return unescapeHTML(str).replace(/&/g,"%26").replace(/ /g,"%20");
}

/**
	Trova #H3testoFlash e sostituiscilo con Flash
*/
function H3Flash(nomeElemento) {
	if(document.getElementById(nomeElemento)) {
		var h3Title = document.getElementById(nomeElemento);
		if(flash.installed && (flash.version >= 8)) {
			// Replace top title with flash movie
			var titleText = escapeHTMLforFRT(h3Title.innerHTML);		
			var titleSwf;
			
			titleSwf = '<embed src="multimedia/generale/flash/H3-titolo.swf?titleText='+titleText+'"" menu="false" quality="high" width="160px" height="25px" type="application/x-shockwave-flash" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer"  bgcolor="#424242" wmode="transparent" />';
			h3Title.innerHTML = "<span style='display:none'>"+h3Title.innerHTML+"</span>"+titleSwf;	
			
		}
		
		h3Title.style.visibility = "visible";
	} 
}
/**

/**
	Trova #H4testoFlash e sostituiscilo con Flash
*/
function H4Flash(nomeElemento) {
	if(document.getElementById(nomeElemento)) {
		var h4Title = document.getElementById(nomeElemento);
		if(flash.installed && (flash.version >= 8)) {
			// Replace top title with flash movie
			var titleText = escapeHTMLforFRT(h4Title.innerHTML);		
			var titleSwf;
			
			titleSwf = '<embed src="multimedia/generale/flash/h4-titolo.swf?titleText='+titleText+'"" menu="false" quality="high" width="160px" height="25px" type="application/x-shockwave-flash" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer"  bgcolor="#424242" wmode="transparent" />';
			h4Title.innerHTML = "<span style='display:none'>"+h4Title.innerHTML+"</span>"+titleSwf;	
			
		}
		
		h4Title.style.visibility = "visible";
	} 
}

/**
	Trova #H2testoFlash e sostituiscilo con Flash
*/
function H2Flash(nomeElemento) {
	if(document.getElementById(nomeElemento)) {
		var h2Title = document.getElementById(nomeElemento);
		if(flash.installed && (flash.version >= 8)) {
			// Replace top title with flash movie
			var titleText = escapeHTMLforFRT(h2Title.innerHTML);		
			var titleSwf;
			
			titleSwf = '<embed src="multimedia/generale/flash/h2-titolo.swf?titleText='+titleText+'"" menu="false" quality="high" width="500px" height="30px" type="application/x-shockwave-flash" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer"  bgcolor="#424242" wmode="transparent" />';
			h2Title.innerHTML = "<span style='display:none'>"+h2Title.innerHTML+"</span>"+titleSwf;	
			
		}
		
		h2Title.style.visibility = "visible";
	} 
}

//Check the sercah form before submitting
function CheckFormSearch () {
	//Check for a word to search
	if (document.form_search.search.value==""){
		alert("Please enter at least one keyword to search");
		document.form_search.search.focus();
		return false;
	}
	
	return true
}
