/**
*	Enel Main @RMG Connect - Cirone Gianluca
*	
*/
if(document.location.href.indexOf('www.')==-1)
{
	document.location.href='http://www.citrosodina.it/index.htm';
}

var ie = document.all ? true : false;
var pc = navigator.platform == "Win32" ? true : false;
var iphone = navigator.platform == "iPhone" ? true : false;
var chrome = navigator.userAgent.indexOf("Chrome") != -1 ? true : false;
var safari = navigator.userAgent.indexOf("Safari") != -1 ? true : false;

var objMain;
var idObjMain = "main_fl";
var paramsSWF = {};	
var flashvarsSWF = {};
var attributesSWF = {};

var expressInstall = "js/swf/expressinstall.swf";
var version = "10.0.0";
var windowWidth, windowHeight, wfl, hfl;
var minW = 1000;
var minH = 590;

var isTweening = true;

var zoomLevel=0;

//var URL="http://www.rmgtools.com/citrosodina/";
var URL="http://www.citrosodina.it/";
//var URL="http://localhost/citrosodina/site/bin/";

function setIsTweening(val) {
	isTweening = val;
}

function trace(msg) {
	var oldTxt = $("#trace").html();	
	$("#trace").empty();
  	$("#trace").append(oldTxt + " | " +msg);
}

function loadMainFlash(){
	
	//******** Carico Main Flash ******* 
	if(swfobject.getQueryParamValue("dish"))
		flashvarsSWF.dish = swfobject.getQueryParamValue("dish");
	if(swfobject.getQueryParamValue("sd")) //show home dialog
		flashvarsSWF.sd = swfobject.getQueryParamValue("sd");
	paramsSWF.allowscriptaccess = "always";
	paramsSWF.scale = "noscale";
	//paramsSWF.salign = "tl";	
	//paramsSWF.wmode = "transparent"; //**** FUCK WMODE *****
	attributesSWF.id = idObjMain;
	attributesSWF.name = idObjMain;
	attributesSWF.xiRedirectUrl = "http://www.citrosodina.it/";
	swfobject.embedSWF("swf/main.swf", "main_flash", "815", "495", version, expressInstall, flashvarsSWF, paramsSWF, attributesSWF);

			setTimeout(function() {		
			if(ActiveFacebook){
				objMain = swfobject.getObjectById(idObjMain);
				ActiveFacebook.init("eb3f5a5372129b760e38116b4b5e36b6");
				ActiveFacebook.addFlashDelegate(objMain);
			}
		}, 500);

}

function loadSpotFlash(){
	
	//******** Carico Spot Flash ******* 
	paramsSWF.allowscriptaccess = "always";
	paramsSWF.scale = "noscale";
	swfobject.embedSWF("swf/spot.swf", "spot_flash", "815", "495", version, expressInstall, {}, paramsSWF, {});
}

function loadProdSideFlash()
{
	paramsSWF.allowscriptaccess = "always";
	paramsSWF.scale = "noscale";
	swfobject.embedSWF("swf/prod_side.swf", "prod_side_flash", "168", "246", version, expressInstall, {}, paramsSWF, {});
}

function clickMenu(e){	
	var obj = e.currentTarget;	
	var index = obj.id.substring(5, obj.id.length);
	
	if(index==0){
		location.href = URL+"citrosodina-bustine.htm";
	}else if(index==1){
		location.href = URL+"citrosodina-masticabile.htm";
	}else if(index==2){
		location.href = URL+"citrosodina-granulare.htm";
	}else if(index==3){
		location.href = URL+"digestione.htm";
	}else if(index==4){
		location.href = URL+"spot-tv.htm";
	}
	
	//alert(PATH);
}

function openMenu(e){
	var obj = e.currentTarget;	
	var index = obj.id.substring(5, obj.id.length);	
	obj.src = URL+"img/menu_item"+index+"_over.jpg";	
}

function closeMenu(e){
	var obj = e.currentTarget;	
	var index = obj.id.substring(5, obj.id.length);
	obj.src = URL+"img/menu_item"+index+".jpg";
}

//da x=0 a x=1 19/04/11

function activeMenu(){		
	for(x=0;x<5;x++){
		if($("#item_"+x)){
			$("#item_"+x).css("cursor", "pointer");
			$("#item_"+x).mouseover(openMenu);
			$("#item_"+x).mouseout(closeMenu);
			$("#item_"+x).click(clickMenu);
		}
	}	
}

function zoomIn(internal)
{
	if(zoomLevel<2)
	{
		zoomLevel++;
		
		document.getElementById('inside_body').style.fontSize=(11+zoomLevel+'px');
		var imgPath="url("+URL+"img/size"+(zoomLevel+1)+".jpg)";
		document.getElementById('zoom').style.backgroundImage=imgPath;
	}
}

function zoomOut(internal)
{
	if(zoomLevel>0)
	{
		zoomLevel--;
		document.getElementById('inside_body').style.fontSize=(11+zoomLevel+'px');
		var imgPath="url("+URL+"img/size"+(zoomLevel+1)+".jpg)";
		document.getElementById('zoom').style.backgroundImage=imgPath;
	}
}

function addingFavorite()
{
	var title=document.title;
	var url=location.href;
	
	 if ($.browser.mozilla == true)
	{
		window.sidebar.addPanel(title,url,"");
	}
	else if($.browser.msie == true)
	{
		window.external.AddFavorite(url,title);
	}
}

function printContent()
{
	var a = window.open('','','width=665,height=400');
	a.document.open("text/html");
	a.document.write('<html><head></head><body>');
	a.document.write('<font size="4px" face="Tahoma">'+document.getElementById('inside_head').innerHTML+'</font><br/>');
	a.document.write('<font size="2px" face="Tahoma">'+document.getElementById('inside_body').innerHTML+'</font>');
	a.document.write('</body></html>');
	a.document.close();
	a.print(); 
}

$(document).ready(function()
{
	 activeMenu();
	
	 if($("#main_flash")) loadMainFlash();
	 if($("#spot_flash")) loadSpotFlash();
	 if($("#prod_side_flash")) loadProdSideFlash();
	
});





