//indirizzo sito
var sito = window.location.href ;
//sito
sito = sito.replace("http://",""); 
//ottengo strLivello
var arySito = sito.split(".");
var strLivello= arySito[0].toLowerCase();

var arySito2 = sito.split("/");
var strLivello2 = arySito2[0].toLowerCase(); 

//in base al livello agisco in lingua
switch( strLivello2 )
	{
		case "www.sbs-power.it": //italiano
		  
		  //etichette
		  eti00 =  "Inserisci almeno un criterio di filtraggio !";
		  eti01 = 'Inserisci username'
		  eti02 = 'Inserisci password'
		  eti03 = "Inserisci la data di acquisto !";
		  eti04 = "Inserisci la cittā di acquisto !";
		  eti05 = "Inserisci la nazione di acquisto !";
		  eti06 = "Inserisci il tipo di documento di acquisto !";
		  eti07 = "Inserisci il numero di documento !";
		  eti08 = "Inserisci il nome!";
		  eti09 = "Inserisci il cognome !";
		  eti11 = "Inserisci il codice fiscale !";
		  eti12 = "Inserisci la username !";
		  eti13 = "Inserisci la password !";
		  eti14 = "Inserisci la mail !";
		  eti15 = "Inserisci il numero di telefono !";
		  eti16 = "Inserisci l'indirizzo !";
		  eti17 = "Inserisci la citta' !";
		  eti18 = "Inserisci il cap !";
		  eti19 = "Inserisci la provincia !";
		  eti20 = "Inserisci la nazione !";

		  eti21 = "Inserisci la data di nascita !"
		  eti22 = "Inserisci il luogo di nascita !"
		  eti23 = "Inserisci la provincia di nascita !"
		  eti24 = "Inserisci lo stato civile !"
		  eti25 = "Inserisci la Provincia di nascita !"		  
		  eti26 = "Inserisci il sesso !"	
		  eti27 = "Inserisci il numero di cellulare !"
		  eti28 = "Inserisci un indirizzo e-mail valido !"
		  eti29 = "Inserisci le tue aspettative !"
		  eti30 = "L'accettazione della privacy č obbligatoria !"
		  
		  eti31 = "Inserisci il codice antispam !"
		  
		  break;
		  
		  case "www.sbs-power.com": //inglese
		  
			  //etichette
			  eti00 =  "Please enter at least one filtering policy !";
			  eti01 = 'Enter username'
			  eti02 = 'Enter password'
			  eti03 = "Enter date of purchase !";
			  eti04 = "Enter city of purchase !";
			  eti05 = "Enter state of purchase !";
			  eti06 = "Enter type of Document of purchase !";
			  eti07 = "Enter number of document of purchase !";
			  eti08 = "Enter the name !";
			  eti09 = "Enter the surname !";
			  eti11 = "Enter the tax code !";
			  eti12 = "Enter the username !";
			  eti13 = "Enter the password !";
			  eti14 = "Enter the e-mail !";
			  eti15 = "Enter the telephone number !";
			  eti16 = "Enter the address !";
			  eti17 = "Enter the city !";
			  eti18 = "Enter the ZIP code !";
			  eti19 = "Enter the province !";
			  eti20 = "Enter the country !";
	
			  eti21 = "Enter your date of birth !"
			  eti22 = "Enter the place of birth !"
			  eti23 = "Enter the province of birth !"
			  eti24 = "Enter the marital status !"
			  eti25 = "Enter the country of birth !"		  
			  eti26 = "Enter the gender !"	
			  eti27 = "Enter your mobile number !"
			  eti28 = "Please enter a valid e-mail address!"
			  eti29 = "Enter your expectations !"
			  eti30 = "Acceptance of privacy is required !"
			  
			  eti31 = "Enter the antispam code !"
		  break;

	}
	
	
//captcha
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}


//condividi su fb
(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) {return;}
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

//condividi su tw
(function(d,s,id){
	var js,fjs=d.getElementsByTagName(s)[0];
	if(!d.getElementById(id))
	{js=d.createElement(s);js.id=id;
	js.src="//platform.twitter.com/widgets.js";
	fjs.parentNode.insertBefore(js,fjs);
}}(document,"script","twitter-wjs"));

//valore iniziale input ricerca
var val_ini  = ""
$(document).ready(function() {
	val_ini = $("#str_src").val()
});
function input_focus(){
	if ( $("#str_src").val() == val_ini ) { $("#str_src").val("") }
}
function input_change(){
	if (  $("#str_src").val() == "") { $("#str_src").val(val_ini) }
}   


//scelta lingua
var mouse_is_inside = false;
var div_is_open = false;

$(document).ready(function(){    					   
	$("#lan-but").click( 
		function () {
			if ( div_is_open == false )
				{
					$('#choose-language').show('slow', function() {});
					div_is_open = true;
				}
			else
				{
					$('#choose-language').hide('slow', function() {});
					div_is_open = false;
				}
			$("#lan-but").blur();
		}
	);
	$('#choose-language').hover( function(){ mouse_is_inside=true }, function(){	mouse_is_inside=false } );	 
	$("body").mouseup(function(){
		if(! mouse_is_inside )
		{
			$('#choose-language').hide() 
		}
	});	 
});

	
//init
$(document).ready(function() { 
	
	var url_arr = window.location.href.split('#');
	if ( url_arr.length>=2 )
		{
			if ( url_arr[1] != '!prettyPhoto' )
				{
					$("#" + url_arr[1]).show();
				}			
		}
	
}); 

//go to a sub
function goToSub( sub_url, bool_open )
	{
	
		if ( $("#" + sub_url).is(":visible") && bool_open )
			{
				$("#" + sub_url).hide()	
				 

			}
		else
			{
				$("#" + sub_url).show();
				goToByScroll( sub_url, -40 );
				
			}
		
	}
	
//scroll 
function goToByScroll(id, offset_px ){ 
	$('html,body').animate({ scrollTop: $("#"+id).offset().top + offset_px }, 'slow'); 
} 


//cambia colori
$(document).ready(function() {
	$("a.bt_color").hover(  
		function () {
			//cambia anteprima	( #img-panoramica )
			$("#img-panoramica"  ).attr("src", "/" + this.id );
		},   
		function () {
			//ritorno sulla foto normale
			path_ori = 	$("#img-panoramica_default").val();
			
			$("#img-panoramica"  ).attr("src", path_ori );
		}
	);
});

//controllo form download
function ck_form_download( the_form )
	{
		if ( the_form.dwnl_ger.value =="" &&  the_form.dwnl_txt.value =="")
		{
			alert(eti00);
			return false;
		}
		return true;	
	}

//controllo form login 
function ck_form_login( the_form )
	{
		if ( the_form.usrname.value =="")
		{
			alert(eti01);
			the_form.usrname.focus();
			return false;
		}
		if( the_form.usrpwd.value =="")
		{
			alert(eti02);
			the_form.usrpwd.focus();
			return false;
		}
		return true;	
	}

//controllo form registrazione
function ck_att_gar( the_form )
	{
		
		//contollo data
		stringa_contollo= the_form.ur_data_acquisto.value;						
		var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
		if (!espressione.test(stringa_contollo)){	
			alert(eti03);
			the_form.ur_data_acquisto.focus();
			return false;
		}

		if( the_form.ur_citta_acquisto.value =="")
		{
			alert(eti04);
			the_form.ur_citta_acquisto.focus();
			return false;
		}
		if( the_form.ur_nazione_acquisto.value =="")
		{
			alert(eti05);
			the_form.ur_nazione_acquisto.focus();
			return false;
		}
		if( the_form.ur_tipo_documento.value =="")
		{
			alert(eti06);
			the_form.ur_tipo_documento.focus();
			return false;
		}
		if( the_form.ur_num_documento.value =="")
		{
			alert(eti07);
			the_form.ur_num_documento.focus();
			return false;
		}
		return true;	
	}
	
//controllo form profilo
function ck_form_profilo( the_form )
	{
		
		if( the_form.ute_nome.value =="")
		{
			alert(eti08);
			the_form.ute_nome.focus();
			return false;
		}
		if( the_form.ute_cognome.value =="")
		{
			alert(eti09);
			the_form.ute_cognome.focus();
			return false;
		}
		if( the_form.ute_nome.value =="")
		{
			alert(eti10);
			the_form.ute_nome.focus();
			return false;
		}
		if( the_form.ute_cf.value =="")
		{
			alert(eti11);
			the_form.ute_cf.focus();
			return false;
		}
		if( the_form.ute_username.value =="")
		{
			alert(eti12);
			the_form.ute_username.focus();
			return false;
		}
		if( the_form.ute_pwd.value =="")
		{
			alert(eti13);
			the_form.ute_pwd.focus();
			return false;
		}
		//e-mail			
		var emailadd = the_form.ute_mail.value;
		if (emailadd.indexOf('@', 0) == -1 || emailadd.indexOf('.', 0) == -1)
		{ 
			alert(eti14);
			the_form.ute_mail.focus();
			return false;
		}
		if( the_form.ute_tel.value =="")
		{
			alert(eti15);
			the_form.ute_tel.focus();
			return false;
		}
		
		if( the_form.ute_indirizzo.value =="")
		{
			alert(eti16);
			the_form.ute_indirizzo.focus();
			return false;
		}
		
		if( the_form.ute_citta.value =="")
		{
			alert(eti17);
			the_form.ute_citta.focus();
			return false;
		}
		
		if( the_form.ute_cap.value =="")
		{
			alert(eti18);
			the_form.ute_cap.focus();
			return false;
		}
		
		if( the_form.ute_provincia.value =="")
		{
			alert(eti19);
			the_form.ute_provincia.focus();
			return false;
		}
		
		if( the_form.ute_nazione.value =="")
		{
			alert(eti20);
			the_form.ute_nazione.focus();
			return false;
		}
		
		return true;	
	}


//lavora con noi
function ck_form_lavora_con_noi(theForm)
{
		  
	if (theForm.nome.value == "")
	{
	  alert(eti08);
	  theForm.nome.focus();
	  return (false);
	}
	if (theForm.cognome.value == "")
	{
	  alert(eti09);
	  theForm.cognome.focus();
	  return (false);
	}
	if (theForm.gg.value == "" || theForm.mm.value == "" || theForm.aaaa.value == "")
	{
	  alert(eti21);
	  theForm.gg.focus();
	  return (false);
	}
	if (theForm.lnascita.value == "")
	{
	  alert(eti22);
	  theForm.lnascita.focus();
	  return (false);
	}
	if (theForm.provincianascita.value == "--")
	{
	  alert(eti23);
	  theForm.provincianascita.focus();
	  return (false);
	}
	if (theForm.statocivile.value == "--")
	{
	  alert(eti24);
	  theForm.statocivile.focus();
	  return (false);
	}
	if (theForm.sesso.value == "--")
	{
	  alert(eti26);
	  theForm.sesso.focus();
	  return (false);
	}
	if (theForm.indirizzo.value == "")
	{
	  alert(eti16);
	  theForm.indirizzo.focus();
	  return (false);
	}

	if (theForm.citta.value == "")
	{
	  alert(eti17);
	  theForm.citta.focus();
	  return (false);
	}
	if (theForm.cap.value == "")
	{
	  alert(eti18);
	  theForm.cap.focus();
	  return (false);
	}
	if (theForm.provinciaresidenza.value == "--")
	{
	  alert(eti19);
	  theForm.provinciaresidenza.focus();
	  return (false);
	}
	if (theForm.email.value.indexOf('@', 0) == -1 || theForm.email.value.indexOf('.', 0) == -1)
	{ 
	  alert(eti28);
	  theForm.email.focus();
	  return (false);
	}
	if (theForm.aspettative.value == "")
	{
	  alert(eti29);
	  theForm.aspettative.focus();
	  return (false);
	}
	
	if (!(theForm.privacy.checked))
	{
	  alert(eti30);
	  theForm.privacy.focus();
	  return (false);
	}
	
	if (theForm.captchacode.value == "")
	{
	  alert(eti31);
	  theForm.captchacode.focus();
	  return (false);
	}
	
	return (true);
}
