//////////////////////////////////// 
var toolVars = null;
//////////////////////////////////// 
function oPage( p, w, h, title ){
	if(!w) w = 440;
	if(!h) h = 260;
	if(!title) title = '';
	var features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',dependent=1';
	window.popUpWin = window.open(p, title, features);
	window.popUpWin.focus();
}
//////////////////////////////////// 
function writeFlash( xName, xPath, W, H, xVars, xTrasp, xScale, xResponse ){


//alert( GetSwfVer() );

	xVars += "&appExt=php&";
	strSwf = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + '\r';
	strSwf += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ' + '\r'; 
	strSwf += 'width="' + W + '" height="' + H + '" id="' + xName + '" align="middle"> ' + '\r';
	strSwf += '<param name="FlashVars" value="' + xVars + '">' + '\r';
	if( xScale ) 				strSwf += '<param name="Scale" value="' + xScale + '">' + '\r';
	if( xTrasp==true ) 	strSwf += '<param name="wmode" value="transparent"> ' + '\r';
	strSwf += '<param name="allowScriptAccess" value="sameDomain"> ' + '\r';
	strSwf += '<param name="movie" value="' + xPath + '"> ' + '\r';
	strSwf += '<embed FlashVars="' + xVars + '"  ';
	strSwf += 'src="' + xPath + '" width="' + W + '" height="' + H + '" name="' + xName + '" align="middle" ' ;
	if( xScale ) 				strSwf += 'scale="' + xScale + '"  ';
	if( xTrasp==true ) 	strSwf += 'wmode="transparent" ';
	strSwf += 'swLiveConnect="true" ';
	strSwf += 'allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" /> ' + '\r';
	strSwf += '</object>';

	if( !xResponse ){
		document.write( strSwf );
	} else {
		return strSwf;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getDivStyle( xTg ){
	if( document.layers ){ 
		return eval('document.'+xTg); 
	}
	var xDiv = document.getElementById(xTg);
	if( xDiv ){
		if( xDiv.style ) return xDiv.style;
	}
	return;
}
//////////////////////////////////// 
function submitCommonForm( xForm, xURL ){
	var myForm = document.getElementById( xForm );
	if( xURL ){
		myForm.action = myForm.action + xURL;
	}
	myForm.submit();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
function carrelloTimerSubmit( xIDitem ){
	setTimeout("submitCommonForm('customForm"+xIDitem+"')", 1000); 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////////////////////////////////// Cookie
function parseCookie() {
	//////////////////////////////////// 
	var cookieList = document.cookie.split("; ");
	var cookieArray = new Array();
	for (var i=0; i<cookieList.length; i++) {
		var name = cookieList[i].split("=");
		cookieArray[unescape(name[0])] = (name.length==2)?unescape(name[1]):'';
	}
	return cookieArray;
	//////////////////////////////////// 
}
function setCookie( strCookie ){
	//////////////////////////////////// 	
	var expireDate = new Date();
	expireDate.setDate(365 + expireDate.getDate());
	strCookie += "; expires=" + expireDate.toGMTString()+";"; 
	document.cookie = strCookie;
	//////////////////////////////////// 	
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
function applyHandle( xHandle, xFunction ){
	if( document.layers ){ 		//NS
		document.body[xHandle] = xFunction;
	}else if( document.all ){ //IE
		document.body[xHandle] = xFunction;
	} else {									//MO
		this[xHandle] = xFunction;
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////////////////////////////////// File Utility
function getFileExt( filePath ){
	var arrExt = filePath.split(".");
	if( arrExt.length>0 ) return arrExt[arrExt.length-1].toLowerCase(); 
	return '';
}
function getFileName( filePath ){
	filePath = filePath.replace(/\//ig,'\\');
	var arrPath = filePath.split("\\");
	if( arrPath.length>0 ) return arrPath[arrPath.length-1]; 
	return '';
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
function GetBrowser(){
	////////////////////////////////////
	if( navigator.appName.indexOf("Microsoft") > -1 ){
		return 'IE';
	} else {
		return 'FF';
	}
	////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
function IncludeJavaScript( jsFile ){
  document.write('<scr' + 'ipt language="javascript1.2" type="text/javascript" src="' + jsFile + '"></scr' + 'ipt>'); 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 





////////////////////////////////////////////////////////////////////////////////////////////////////////////  Hide/View DIV
function setDivView( xDiv ){
	//////////////////////////////////// 
	var curDiv = getDivStyle(xDiv);
	//////////////////////////////////// 
	if(curDiv.display == "none"){

		curDiv.display = "";
		document.getElementById("bt"+xDiv).className = "click"+xDiv+"open";
		
	}else{
	
		curDiv.display = "none";
		document.getElementById("bt"+xDiv).className = "click"+xDiv;
	
	}
	//////////////////////////////////// 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 


////////////////////////////////////////////////////////////////////////////////////////////////////////////
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ControlVersion(){
	///////////////////////////////
	var version;
	var axo;
	var e;
	///////////////////////////////
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {	}
	if (!version)	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "6,0,21,0";
			axo.AllowScriptAccess = "always";
			version = axo.GetVariable("$version");
		} catch (e) {	}
	}
	if (!version)	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {	}
	}
	if (!version)	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	///////////////////////////////
	return version;
	///////////////////////////////
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetSwfVer(){
	///////////////////////////////
	var flashVer = -1;
	///////////////////////////////
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	///////////////////////////////
	flashVer = String(flashVer).replace('WIN ', '');
	///////////////////////////////
	return flashVer;
	///////////////////////////////
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////////////////////////////////// MENU TD SPLITTER
function menuSplitter( xMenuTab ){
	var myTable = document.getElementById(xMenuTab);
	var cellTot = myTable.rows[0].cells.length;
	var myWidth = Math.round(myTable.width/cellTot);
	
	for( i=0; i<cellTot; i++){
		myTable.rows[0].cells[i].style.width = myWidth + 'px';
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////////////////////////////////// Set Site as default page
function setHomepage() {  
	if (document.all)     {         
		document.body.style.behavior='url(#default#homepage)';   
		document.body.setHomePage('http://www.Ristorante Galleria.it');      
	}else if(window.sidebar){     
		if(window.netscape){          
			try{               
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");            
			}
			catch(e){               
				alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");            
			}     
		}      			
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);     
		prefs.setCharPref('browser.startup.homepage','http://www.Ristorante Galleria.it');  
	} 
} 
////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ChangeDynamicClass( xLink, xItem, xStyle, xStyleSel){
  var Link = xLink;
  var IDchunk = Link.substr(Link.indexOf('diditem='));
  var DivS = document.getElementById(xItem);
  if(window.location.href.indexOf( IDchunk )>=0){      
    DivS.className = xStyleSel;       
  }else{
    DivS.className = xStyle;
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////////////
function SetCheckBoxArray( xID, xValues){
  if(xID.constructor == Array && xValues.constructor == Array){
    if(xID.length == xValues.length){
      for(i=0;i<xID.length;i++){
        if(xValues[i] == true){
          document.getElementById(xID[i]).checked=true;
        } else {
          document.getElementById(xID[i]).checked=false;
        }                                               
      }
    }
  }
  
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////// Set Title Link
function SetTitleLink( xTitleClass, xTitle0, xTitle1 ){
	var myHTML = '<!--title0--><div class="' + xTitleClass + '">' + xTitle0 + '</div><!--/title0-->';
	if(xTitle1 != ''){
		myHTML = '<a href="' + xTitle1 + '" style="text-decoration:none;">' + myHTML + '</a>';
	}
	document.write(myHTML);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
