/*
var swfversion = deconcept.SWFObjectUtil.getPlayerVersion();
var noflash = deconcept.util.getRequestParameter("noflash");
var printerfriendly = deconcept.util.getRequestParameter("printerfriendly");
var flash = deconcept.util.getRequestParameter("flash");
if (flash=='yes') eraseCookie('flash');
if (flash=='no'||readCookie('flash')=='no') {createCookie('flash','no',1); noflash=1;}
if (document.getElementById && (swfversion['major'] > 8) && noflash=='' && printerfriendly=='') {
	document.writeln("<STYLE>.divFlash{display:block;}.divHtml{display:none;}</"+"STYLE>");
}
*/

var debug = true;
/* ==================== */

$(document).ready(function(){


  	if (!MM_FlashCanPlay) {
		var u = $(".gallery").attr("href");
			if(typeof(u)!='undefined') {
			if (u.indexOf('?')<0) {
				u+="?noflash=1";
			} else {
				u+="&noflash=1";
			}
			$(".gallery").attr("href",u);
		}
	}

	$("a.iframe1").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 535,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
    
    $("a.iframe1d").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 635,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
    $("a.iframe1d_fr").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 685,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	
	$("a.iframe2").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1019,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	$("a.iframe3").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 940,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	$("a.iframe4").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1115,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	
	
	
	
	$("a.iframe1_fr").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 575,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	
	$("a.iframe2_fr").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1140,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	$("a.iframe3_fr").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1250,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	$("a.iframe4_fr").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1100,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
   

	$('#menuMain .lev1 > a').each(function(index) {
		var newText2 = $(this).text();
		var finalText = newText2.replace(' ','<br />');
		$(this).html(finalText);		
	});
	
	
   $("#footer .links #menu_en_fp_automation_htm > a").addClass("iframe1_foot");
   $("#footer .links #menu_en_fp_automation_htm1 > a").addClass("iframe1_foot");
   //$("#footer .links #menu_en_fp_marketing_htm a").addClass("iframe2_foot");
   $("#footer .links #menu_en_fp_environmenti_htm a").addClass("iframe3_foot");
   $("#footer .links #menu_en_fp_dataonline_htm a").addClass("iframe3_foot2");
   $("#footer .links #menu_fr_fp_dataonline_htm a").addClass("iframe4_fr_foot");
   
   $("a.iframe1_foot").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 535,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	 $("a.iframe4_fr_foot").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1100,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
    $("a.iframe3_foot2").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 940,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	/*$("a.iframe2_foot").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1019,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});*/
    
	$("a.iframe3_foot").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1205,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});
	/*$("a.iframe4_foot").fancybox({
		'autoDimensions': false,
		'autoScale': false,
		'width': 600,
		'height': 1115,
		'hideOnContentClick': true,
		'type': 'iframe',
		'scrolling': 'no',
		'padding': 0
	});*/
    
    addVideoPop();
	
	init();
})

/* this function is called when the page is ready or after an ajax call has completed */


function addVideoPop() {

$(".videopopup").click(function() {

pathArray = String(this.href).split( '/' ); 
host = pathArray[2];


if (host == "www.youtube.com"){
    $.fancybox({
        'padding'       : 0,
        'autoScale'     : false,
        'transitionIn'  : 'none',
        'transitionOut' : 'none',
        'width'         : 640,
        'height'        : 385,
        'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
        'type'          : 'swf',
        'swf'           : {
            'wmode'             : 'transparent',
            'allowfullscreen'   : 'true'
        }
    });
} else {
     $.fancybox({
        'padding'       : 0,
        'autoScale'     : false,
        'transitionIn'  : 'none',
        'transitionOut' : 'none',
        'width'         : 640,
        'height'        : 385,
        'href'          : this.href,
        'type'          : 'iframe',
        'swf'           : {
            'wmode'             : 'transparent',
            'allowfullscreen'   : 'true'
        }
    });

}
return false;
});         

}

function init() {

    $('.do_image').mouseover(function() {
        $(this).width(550);
    });
    $('.do_image').mouseout(function() {
        $(this).width(300);
    });

	$(".gallery").addClass('iframe');
	
	/* image = 640 x 368, height = 368 + 64 + 2 = 434 */
	$(".gallery").fancybox({
		'showCloseButton': true,
		'type': 'iframe',
		'scrolling': 'no',
		'width': '90%',
		'height': 576
	});

}

function closeAndMove(url){
	parent.$.fancybox.close();
	window.location(url);
}


// flash detection!
var MM_contentVersion = 8;/* 8 */
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
