// Dropdown Menu
var timeout         = 100;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul.content').eq(0).css('display', 'block');
	
	if ($(this).find('ul.content li.categories ul.Fcol').eq(0).css('width')){
		widthItem1 = $(this).find('ul.content li.categories ul.Fcol').eq(0).css('width');
		widthItem2 = $(this).find('ul.content li.categories ul.Scol').eq(0).css('width');
		if ( $(this).find('ul.content li.extra').eq(0).css('width') ){
			
			widthItem3 = $(this).find('ul.content li.extra').eq(0).css('width');
		
		}else{
			
			widthItem3 = 0;
		}
		totWidth = parseInt(widthItem1) + ( parseInt(widthItem2)+ 20 ) + parseInt(widthItem3);
	}else{
		
		widthItem1 = $(this).find('ul.content li.categories').eq(0).css('width');
		widthItem2 = $(this).find('ul.content li.extra').eq(0).css('width');
		totWidth = ( parseInt(widthItem1) + 3 ) + parseInt(widthItem2);		
		
	}
	//alert(jQuery.browser.mozilla);
	//alert(widthItem1 + " - " + widthItem2 + " - " + widthItem3);
	//alert(totWidth);
	
	if (jQuery.browser.mozilla != true){
		
		menuitem = $(this).find('ul.content').eq(0).css('width', totWidth + 'px');
		
	}
	
	
	//alert(ddmenuitem.css('width'));
	current = $(this).find('a.first').css('background-color', '#2251a3');
}

function jsddm_close()
{
	if(ddmenuitem){
		ddmenuitem.css('display', 'none');
		current.css('background', 'none');
	}
}

function jsddm_timer()
{
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

$(document).ready(function()
{
	//setSizeIE();
	$('#nav > li').bind('mouseover', jsddm_open);
	$('#nav > li').bind('mouseout',  jsddm_timer);
});

document.onclick = jsddm_close;






function tabSel(tab)
{
	
	if (tab == 'tab-1')
	{
		//alert("show tab1 hide tab 2");
		var getTab = document.getElementById('tab-1');
		getTab.style.display = 'block';
		var selTab = document.getElementById('tab-scheda');
		selTab.className = 'sel-tab';
		
		var getTabUnsel = document.getElementById('tab-2');
		getTabUnsel.style.display = 'none';
		var selTab = document.getElementById('tab-rece');
		selTab.className = 'tab';			
	}
	else
	{
		//alert("show tab2 hide tab 1");
		var getTab = document.getElementById('tab-2');
		getTab.style.display = 'block';
		var selTab = document.getElementById('tab-rece');
		selTab.className = 'sel-tab';
		
		var getTabUnsel = document.getElementById('tab-1');
		getTabUnsel.style.display = 'none';
		var selTab = document.getElementById('tab-scheda');
		selTab.className = 'tab';						
	}
}


function showFloorAd()
{
	
	if (getCookie("floorAD") != ""){
		
		
		
		return;
	}else{
		
		var getFloorAdDiv = document.getElementById('floor-ad');
		getFloorAdDiv.style.display = '';
		SetCookie("floorAD", "visitor", 1);
		intervallo = setInterval('clearFloorAd()',20000);		
		
		

	}


	
}

function clearFloorAd()
{

	var getFloorAdDiv = document.getElementById('floor-ad');
	getFloorAdDiv.style.display = 'none';	
	clearInterval(intervallo);
}



function SetCookie(cookieName,cookieValue,nDays) {
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue)
	                 + ";expires="+expire.toGMTString() + ";domain=dvd.it;";
	}

	function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    {
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    }
	  }
	return "";
	}	
	
	

function check(chk){
	if (chk.checked == 0){
	    //alert("Thank You");
	  	document.getElementById('subNl').disabled = false;
	  	var msgErr = document.getElementById('msgCheck');
	  	//msgErr.innerHTML = '';	  	
	  	msgErr.style.display = 'none';
	  	
	  	var hideFaux = document.getElementById('submitBtFaux');	  	
	  	hideFaux.style.display = 'none';
	  	
	  	var  showReal = document.getElementById('submitBt');	  	
	  	showReal.style.display = '';	  	
	  	//checkEmail();
	    
	}else{
	  	document.getElementById('subNl').disabled = true;
	  	
	  	
	  	var hideFaux = document.getElementById('submitBtFaux');	  	
	  	hideFaux.style.display = '';
	  	
	  	var  showReal = document.getElementById('submitBt');	  	
	  	showReal.style.display = 'none';	  	
	  	//var msgErr = document.getElementById('msgCheck');
	  	//msgErr.style.display = '';
	  	//msgErr.innerHTML = 'Devi accettare la normativa sulla privacy';
	  	
	    //alert("You didn't check it! Let me check it for you.");
	    //chk.checked = 0; 
	}
}

function check_submit(){
	
	var chk = document.getElementById('wishNL');
	//alert(chk.checked);
	
	if (chk.checked == false){
		
	    //alert("Thank You");
	  	//document.getElementById('subNl').disabled = false;
	  	var msgErr = document.getElementById('msgCheck');
	  	//msgErr.innerHTML = '';	  	
	  	msgErr.style.display = '';
	  	//checkEmail();
	    
	}else{
		
	  	//document.getElementById('subNl').disabled = true;
	  	var msgErr = document.getElementById('msgCheck');
	  	msgErr.style.display = 'none';
	  	//msgErr.innerHTML = 'Devi accettare la normativa sulla privacy';
	  	
	    //alert("You didn't check it! Let me check it for you.");
	    //chk.checked = 0; 
	}
}

function disableEnterKey()
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE

     if(key == 13){
    	 
         return false;
     }
     else{
    	 
         return true;
     }
}

function show_privacy2()
{
  privacy=window.open('/privacy/privacy/','privacy','channelmode=0,directories=0,fullscreen=0,height=700,left='+((screen.availWidth/2)-300)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=600');
}

function showProduct()
{

  var getProductSH = document.getElementById('SHProduct');
  if (getProductSH.style.display == 'none')
  {
    getProductSH.style.display = '';
   
  }
  
}
// mostra o nasconde le recensioni
function hideReviews()
{
	getReviewsToHide = document.getElementById('allReviews');
	getReviewsToHide.style.display = 'none';
}

function showReviews()
{

  var getReviews = document.getElementById('allReviews');
  if (getReviews.style.display == 'none')
  {
	  getReviews.style.display = '';
	  //var getLinkReviews = document.getElementById('linkReviews');
	  //getLinkReviews.innerHTML = 'Nascondi tutte le recensioni';
   
  }else
  {
	  
	  getReviews.style.display = 'none';
	  //var getLinkReviews = document.getElementById('linkReviews');
	  //getLinkReviews.innerHTML = 'Visualizza tutte le recensioni';
	  
  }
  
}


/* DISNEY */
function hideTab()
{

		var tabID = document.getElementById('blu');
		tabID.style.display = 'none';

		var tabID2 = document.getElementById('pres');
		tabID2.style.display = 'none';

		var tabID3 = document.getElementById('anim');
		tabID3.style.display = 'none';

		var tabID5 = document.getElementById('filmd');
		tabID5.style.display = 'none';

		var tabID4 = document.getElementById('chann');
		tabID4.style.display = 'none';

}
function show(tab)
{
	//alert(tab);
	var tab = document.getElementById(tab);
	tab.style.display = 'block';

}

function sel(icon)
{
	//alert(icon);
	var icon = document.getElementById(icon);
	icon.style.backgroundPosition = '0 -80px';

}

function deSel(icon)
{
	//alert(tab);
	var icon = document.getElementById(icon);
	icon.style.backgroundPosition = '0 0';

}

function hide(tab)
{

	var tab = document.getElementById(tab);
	tab.style.display = 'none';

}
/* +++++++ */
function showVetrine(tab,sel)
{




    for(i = 0; i <= 4; i++)
    {

		getSel = document.getElementById('sel'+i);
		if(getSel.id == sel)
		{
			getClasse = document.getElementById(sel);
			getClasse.style.backgroundColor = "#e95d0f";
			getClasse.style.backgroundImage = "none";
			getClasse.style.color = "#fff";
			//alert(getClass.class);


		}
		else
		{
			getClasse = document.getElementById('sel'+i);
			getClasse.style.backgroundImage = "url(/templates/DVD/images/B1.gif)";
			getClasse.style.color = "#353535";
			//alert(getClass.class);



		}


        getTab = document.getElementById('tab'+i);

        if(getTab.id == tab)
        {

				if( getTab.id == tab && getTab.style.display == '' ) {
					continue;
				}

	            if(getTab.style.display == '')
	            {
	               getTab.style.display = 'none';
	            }
	            else
	            {
	                getTab.style.display = '';
	            }

        }
        else
        {
			//alert(tab)
            getTab.style.display = 'none';

        }

    }

}
function setTimer()
{
  timeR();
  intervallo = setInterval('timeR()',5000);

}

function callShow(tab,sel)
{
      //alert(tab+"-"+sel);
      clearInterval(intervallo);
      showVetrine('tab'+tab,'sel'+sel);


}

function restartTimer(pos)
{

  j = pos;
  setTimer();

}

var j = 0;
function timeR(){



    slidesArray = new Array()

		slidesArray[0]="0"
		slidesArray[1]="1"
		slidesArray[2]="2"
		slidesArray[3]="3"
		slidesArray[4]="4"



 showVetrine('tab'+slidesArray[j],'sel'+slidesArray[j]);

 j=j+1;


if(j==5) { j=0; }

}





function showTab(tab,sel,altri)
{

  y = 1;
  while( document.getElementById('tab' + y + altri) ){
    theDiv = document.getElementById('tab' + y + altri);
    //theDiv.innerHTML = "trovato tab " + i;
    //alert(theDiv.id);
    y++;
  }
  y--;
  //document.getElementById('totale').innerHTML = "trovati " + i + " tab";
    for(i = 1; i <= y; i++)
    {
		getSel = document.getElementById('sel'+i+altri);
		if(getSel.id == sel+altri)
		{
			getClasse = document.getElementById(sel+altri);
			getClasse.style.background = "url(/templates/FTS/images/bg-tab-orange.gif)";
			//alert(getClass.class);

			getLeftImage = document.getElementById('sel'+i+altri+'L');
			getLeftImage.src = '/templates/FTS/images/sx-tab-orange.gif';

			getRightImage = document.getElementById('sel'+i+altri+'R');
			getRightImage.src = '/templates/FTS/images/dx-tab-orange.gif';
		}
		else
		{
			getClasse = document.getElementById('sel'+i+altri);
			getClasse.style.background = "url(/templates/FTS/images/bg-tab-gray.gif)";
			//alert(getClass.class);

			getLeftImage = document.getElementById('sel'+i+altri+'L');
			getLeftImage.src = '/templates/FTS/images/sx-tab-gray.gif';

			getRightImage = document.getElementById('sel'+i+altri+'R');
			getRightImage.src = '/templates/FTS/images/dx-tab-gray.gif';

		}

        getTab = document.getElementById('tab'+i+altri);
        if(getTab.id == tab+altri)
        {

				if( getTab.id == tab && getTab.style.display == '' ) {
					continue;
				}

	            if(getTab.style.display == '')
	            {
	               getTab.style.display = 'none';
	            }
	            else
	            {
	                getTab.style.display = '';
	            }

        }
        else
        {

            getTab.style.display = 'none';

        }

    }

}

/*nascondi visualizza sezione download*/
function hideBegin()
{
	var Hide = document.getElementById('down');
	Hide.style.display = 'none';

}
function hideDown()
{
	if (document.getElementById('down'))
	{
		var toHide = document.getElementById('down');
		if (toHide.style.display == 'block')
		{
			toHide.style.display = 'none';
		}
		else
		{
			toHide.style.display = 'block';
		}
	}
}
/*nascondi visualizza dati extra*/
function hideDati()
{
	if (document.getElementById('datiextra'))
	{
		var toHide = document.getElementById('datiextra');
		if (toHide.style.display == '')
		{
			toHide.style.display = 'none';
		}
		else
		{
			toHide.style.display = '';
		}
	}
}


/*nascondi visualizza dati extra in generale....*/
function hideDatiExtra(whatToHide)
{
	if (document.getElementById(whatToHide))
	{
		var toHide = document.getElementById(whatToHide);
		if (toHide.style.display == '')
		{
			toHide.style.display = 'none';
		}
		else
		{
			toHide.style.display = '';
		}
	}
}

/* antispam job */
function writeMailto()
{
	if (document.getElementById('a'))
	{



		var getMailid = document.getElementById('a');
		getMailid.href = 'mail'+'to:job'+'@'+'shop.it?subject=Programmatore PHP SENIOR';
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';

		var getMailid = document.getElementById('b');
		getMailid.href = 'mail'+'to:job'+'@'+'shop.it?subject=Programmatore .NET';
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';

		var getMailid = document.getElementById('c');
		getMailid.href = 'mail'+'to:job'+'@'+'shop.it?subject=SEO JUNIOR';
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';

		var getMailid = document.getElementById('d');
		getMailid.href = 'mail'+'to:job'+'@'+'shop.it?subject=SEM JUNIOR';
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';

		var getMailid = document.getElementById('e');
		getMailid.setAttribute("href", 'mail'+'to:job'+'@'+'shop.it?subject=SEM SENIOR' );
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';
		/*
		var getMailid = document.getElementById('f');
		getMailid.setAttribute("href", 'mail'+'to:job'+'@'+'shop.it?subject=GRAFICO JUNIOR' );
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';

		var getMailid = document.getElementById('g');
		getMailid.setAttribute("href", 'mail'+'to:job'+'@'+'shop.it?subject=GRAFICO SENIOR' );
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';
		*/
		var getMailid = document.getElementById('h');
		getMailid.setAttribute("href", 'mail'+'to:job'+'@'+'shop.it?subject=STORE MANAGER' );
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';
		
		var getMailid = document.getElementById('i');
		getMailid.setAttribute("href", 'mail'+'to:job'+'@'+'shop.it?subject=PROGRAMMATORE C++' );
		getMailid.innerHTML = 'jo'+'b@sh'+'op.it';		

	}
}

/* Caricamento chat */
function getchat()
{
	if(document.getElementById('chat') && document.getElementById('hchat'))
	{
		document.getElementById('chat').innerHTML = document.getElementById('hchat').innerHTML;
		document.getElementById('hchat').innerHTML = '';
	}
}
/* Caricamento banner  homepage */
function loadbanners_home()
	{
		bannercounter = 0;

		while(bannercounter != 'halt_home')
		{
			if(document.getElementById('banner_home' + bannercounter) && document.getElementById('hbanner_home' + bannercounter))
			{
                document.getElementById('banner_home' + bannercounter).innerHTML = document.getElementById('hbanner_home' + bannercounter).innerHTML;
                document.getElementById('hbanner_home' + bannercounter).innerHTML = '';
				bannercounter++;
			}
			else
			{
				bannercounter = 'halt_home';
			}
		}
	}
/* Caricamento banner  in generale (pagine custom etc...) */
function loadbanners()
	{
		bannercounter = 0;

		while(bannercounter != 'halt')
		{
			if(document.getElementById('banner' + bannercounter) != 'undefined' && document.getElementById('banner' + bannercounter) != null)
			{
                document.getElementById('banner' + bannercounter).innerHTML = document.getElementById('hbanner' + bannercounter).innerHTML;
                document.getElementById('hbanner' + bannercounter).innerHTML = '';
				bannercounter++;
			}
			else
			{
				bannercounter = 'halt';
			}
		}
	}
/* Footer  */
function show_chi_siamo()
{
  chi_siamo = window.open('/chi-siamo/chi-siamo/','chi_siamo','channelmode=0,directories=0,fullscreen=0,height=640,left='+((screen.availWidth/2)-300)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=560');
}

function show_condizioni_vendita()
{
  condizioni_vendita = window.open('/condizioni-di-vendita/condizioni-vendita/','condizioni_vendita','channelmode=0,directories=0,fullscreen=0,height=700,left='+((screen.availWidth/2)-300)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=600');
}
function show_costi()
{
  costi_spedizione = window.open('/costi-di-spedizione/costi-spedizione/','costi_spedizione','channelmode=0,directories=0,fullscreen=0,height=350,left='+((screen.availWidth/2)-300)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=640');
}
function show_commento()
{
  commento = window.open('/invia-un-commento-sul-sito/invia-commento/','commento','channelmode=0,directories=0,fullscreen=0,height=400,left='+((screen.availWidth/2)-200)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=400');
}
function show_biglietto()
{
  fai_un_regalo = window.open('/fai-un-regalo/popup-regalo/','fai_un_regalo','width=600,height=300 ,toolbar=no, location=no,status=yes,menubar=no,scrollbars=no,resizable=no');
}
function show_garanzia()
{
  costi_spedizione = window.open('/estensione-garanzia-3/servizi/','estensione_garanzia','channelmode=0,directories=0,fullscreen=0,height=300,left='+((screen.availWidth/2)-300)+',location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0,top=100,width=640');
}
function quantita_carrello(id, modifica)
{
	var new_quantita;
	var quantita_attuale_valore;
	quantita_attuale = document.getElementById('quantita_'+id);
	quantita_attuale_valore = parseInt(quantita_attuale.value, 10);
	if(modifica == 'piu')
	{
		new_quantita = quantita_attuale_valore+1;
	}
	if(modifica == 'meno')
	{
		new_quantita = quantita_attuale_valore-1;
		if(new_quantita < 0)
		{
			new_quantita = 0;
		}
	}
	quantita_attuale.value = new_quantita;
}
//  Right
// check multi checkboxes based on the name passed in.
function CheckMultiple(name)
{
	theFrm = document.frmSS;
	for (var i=0; i < theFrm.length; i++)
	{
		fldObj = theFrm.elements[i];
		var fieldnamecheck=fldObj.name.indexOf(name);
		if (fieldnamecheck != -1) {
			if (fldObj.checked) {
				return true;
			}
		}
	}
	return false;
}


function CheckSS(msg)
{
	theFrm = document.frmSS;

	hasDot = theFrm.Email.value.indexOf(".");
	hasAt = theFrm.Email.value.indexOf("@");

	if (hasDot == -1 || hasAt == -1)
	{
		alert(msg);
		theFrm.Email.focus();
		theFrm.Email.select();
		return false;
	}


	return true;
}


/* Dettaglio  */
function select_sku(sku)
{
	document.getElementById('acquista').href = document.getElementById('acquista').href.replace(/\/id-[0-9]+(.*)\//,'/id-'+sku+'$1/');
}

function view_stelle()
{
    star = document.getElementById('voti');
    if(star.style.display == '')
    {
        star.style.display = 'none';
    }
    else
    {
        star.style.display = '';
    }

}

/* Check Lunghezza Recensione */
function check_review_lenght()
{
	var testo;
	var theform;
	testo = document.getElementById('testo');
	theform = document.getElementById('form1');
	if (testo.value.length > 99)
	{
		for (i = 0; i < theform.length; i++) 
		{
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit")
			tempobj.disabled = false;
		}
	}
	else
	{
		for (i = 0; i < theform.length; i++) 
		{
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit")
			tempobj.disabled = true;
		}
	}
	//alert(testo.value.length);
}

function showHidden(toShow)
{
	if (document.getElementById(toShow))
	{
		var toHide = document.getElementById(toShow);
		if (toHide.style.display == '')
		{
			toHide.style.display = 'none';
		}
		else
		{
			toHide.style.display = '';
		}
	}
}

