// JavaScript Document
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function showFlashModal( id, type, urlBase, urlData, title, showClose )
{
	J('body').prepend('<div id="'+id+'" class="container-fullscreen"><div class="container-fullscreen-flash"><div id="'+id+'-flash"></div></div></div>');
	if( showClose == undefined )
		showClose = "close";

	var flashLayout = J('#'+id);
	flashLayout.ready(function(){
		
		switch( type )
		{
			
			case 'pageflip' :
				J('.container-fullscreen-flash').prepend('<h1>'+title+' '+ ( showClose == "close" ? '<a href="#" class="close">Fermer</a>' : '<a href="#" class="retour">Retour</a>' ) +'</h1>');
				swfobject.embedSWF(
					urlBase + "swf/pageflip/pageflip.swf", id+'-flash',
					"1000", "730",
					"10", "expressInstall.swf",
					{
						//urlXML:"<?php echo REL_PATH ?>cloud_data.xml",
						xmlPath: urlData + "data.xml.php"
					},
					{
						menu: "false", 
						quality: "best"
					}
				);
			break;
			
			
			case 'coverflow' :
				J('.container-fullscreen-flash').prepend('<h1>'+title+' '+ ( showClose == "close" ? '<a href="#" class="close">Fermer</a></h1>' : '<a href="#" class="retour">Retour</a>' ) +'</h1>');
				swfobject.embedSWF(
					urlBase + "swf/coverFlow/coverFlow.swf", id+'-flash',
					"1000", "600",
					"10", "expressInstall.swf",
					{
						xmlPath: urlData + "config.xml"
					},
					{
						menu: "false", 
						quality: "best", 
						allowFullscreen: "true"
					}
				);
			break;
			
			default: break;
		}
	
		J('#'+id+' .close').click(function(){
			flashLayout.remove();
		});
		
		J('#'+id+' .retour').click(function(){
			
			//alert(browser+" : ammorced return");
			
			if(browser=='Safari' ) window.history.go(-2);
			else window.history.back();

		});
	});
	
}

function sfHover (idParent)
{
	J("#bloc_publi_ul li")
			.hover(function() {
					J(this).toggleClass("sfhover");
			})
			.bind('mouseout', function() {
					J(this).toggleClass("sfhover");
			});
}


function rotateObj (oObj, deg){ 
var deg2radians = Math.PI * 2 / 360;
   rad = deg * deg2radians ;
    costheta = Math.cos(rad);
    sintheta = Math.sin(rad);

    oObj.filters.item(0).M11 = costheta;
    oObj.filters.item(0).M12 = -sintheta;
    oObj.filters.item(0).M21 = sintheta;
    oObj.filters.item(0).M22 = costheta;
}

