// JavaScript Document

function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = "";
     }
 }
 
function resizeLeft() {
	var hLC = $('.left-col').height();
	$().add('.main-col').css( "min-height", hLC );	
}

$(document).ready(function() {
	var w = $(window).width();
	var h = $(window).height();
	var ratio = (w / h);
	var vML = (w / 2);
	var hML = ((h * 1.42) / 2);
	
	if ( ratio < 1.42 )
	{
		$('.bg-img').removeClass("h-stretch");
		$('.bg-img').addClass("v-stretch");
		$().add('.bg-img').css( "margin-left", -hML );
	}
	else 
	{
		$('.bg-img').removeClass("v-stretch");
		$('.bg-img').addClass("h-stretch");
		$().add('.bg-img').css( "margin-left", -vML );
	}
		
	// Add height of left column to the main column
	resizeLeft();
});

function ending(){
$('#background').html('  <img class="bg-img" src="../media/backgrounds/home.jpg" alt="Bollé" />');
var w = $(window).width();
var h = $(window).height();
var ratio = (w / h);
var vML = (w / 2);
var hML = ((h * 1.42) / 2);	
if ( ratio < 1.42 )
	{
		$('.bg-img').removeClass("h-stretch");
		$('.bg-img').addClass("v-stretch");
		$().add('.bg-img').css( "margin-left", -hML );
	}
	else 
	{
		$('.bg-img').removeClass("v-stretch");
		$('.bg-img').addClass("h-stretch");
		$().add('.bg-img').css( "margin-left", -vML );
	}
$('#content').show();
}

$(window).resize(function() {
	var w = $(window).width();
	var h = $(window).height();
	var ratio = (w / h);
	var vML = (w / 2);
	var hML = ((h * 1.42) / 2);
	
	if ( ratio < 1.42 )
	{
		$('.bg-img').removeClass("h-stretch");
		$('.bg-img').addClass("v-stretch");
		$().add('.bg-img').css( "margin-left", -hML ) ;
	}
	else 
	{
		$('.bg-img').removeClass("v-stretch");
		$('.bg-img').addClass("h-stretch");
		$().add('.bg-img').css( "margin-left", -vML ) ;
	}		
});

 $(document).ready(function() {
	var h = $(window).height();
	var cHeight = (h - 173);
		
	$().add('.product-landing').css( "height", cHeight );
});

$(window).resize(function() {
	var h = $(window).height();
	var cHeight = (h - 173);
		
	$().add('.product-landing').css( "height", cHeight );
});

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
}

function oc(a)
{
    var o = {};
    for(var i=0;i<a.length;i++)
    {
        o[a[i]]='';
    }
    
    return o;
}	

function checkNALanguage(){
    if(google.loader.ClientLocation){
        visitor_country = google.loader.ClientLocation.address.country;
        visitor_countrycode = google.loader.ClientLocation.address.country_code;

        if (visitor_countrycode in oc (['CA','MX','US'])){
            return true;
        }
    }
    
    return false;
}
$().ready(function(){ 

if(location.pathname.match('/uber-bolle') != null){       
            $('#nav_2').addClass('active');
            $('#nav_2').removeClass('menu');
        }
        else if(location.pathname.match('/produkte') != null){       
            $('#nav_3').addClass('active');
            $('#nav_3').removeClass('menu');
        }
        else if(location.pathname.match('/technologie') != null){       
            $('#nav_4').addClass('active');
            $('#nav_4').removeClass('menu');
        }
		else if(location.pathname.match('/athleten') != null){       
            $('#nav_5').addClass('active');
            $('#nav_5').removeClass('menu');
	    }else if(location.pathname.match('/handler') != null){       
            $('#nav_6').addClass('active');
            $('#nav_6').removeClass('menu');
	    }

        $("a.menu").hover(function(){
	        $(this).animate({
		        'paddingTop': '67px'
	        }, "normal");
        }, function(){
	        $(this).animate({
		        'paddingTop': '25px'
	        }, "normal");
        });    
		$("a.menu_fr").hover(function(){
	        $(this).animate({
		        'paddingTop': '57px'
	        }, "normal");
        }, function(){
	        $(this).animate({
		        'paddingTop': '15px'
	        }, "normal");
        });               
   

// formulaire nl
		$("#year").empty();
		for( i = 2011; i >= 1920; i--) {
			
			var contenu = $("#year").html();
			
			$("#year").html(contenu+'<option value="'+i+'">'+i+'</option>');
		}
	
	$('input[type=radio][name=hobbies]').change(function(){
		if($(this).val()== 'Other'){
		$('input[type=text][name=other]').prop('disabled', false);
		}else{
		$('input[type=text][name=other]').prop('disabled', true);
		$('input[type=text][name=other]').val('');
		}
		
	});
	
		
	
});  // fin ready !!


	function checkFormNL() {
		var error = "";
		if (error != '')
		{
			$.prompt("1");
			return false;			
		}
		else
		{		
			return true;
		}
	}
	function nl_subscription(urlPreffix){
		nl_subscription(urlPreffix, 'de');
	}
	function nl_subscription(urlPreffix, local){
		
		var email_nl = $('input[type=text][name=email-news]').val();
		if (wrongemail(email_nl)){
			$.prompt("Wir danken Ihnen, eine gültige E-Mail-Adresse einzugeben.");
		} else {
			 $.post(
					urlPreffix + "/includes/min_nl_subscription.php",
					{
						email : email_nl
					},
					function(result) {
	                if (result == "yes") {
						$('#subscribe').hide();
						tb_show('', '#TB_inline?height=620&width=728&inlineId=nl_subscription');
						$('input[type=text][name=email]').val(email_nl);
					} else if (result == "already") {
						$('#subscribe').hide();
							$.prompt("Diese Adresse wird bereits in unserer Liste.",{
								buttons : {
									Ok : 'false',
									"Komplette meine Informationen" : 'true'
								}, callback : function complete_information(v) {
									$.post(urlPreffix + "/includes/nl_subscription_update.php", { email: email_nl},
										 function(data) {
										 $('#nl_subscription').html(data);
										 tb_show('', '#TB_inline?height=620&width=728&inlineId=nl_subscription');
									$('input[type=text][name=email]').val(email_nl);
										 });
								}
							});
					} else {
						$('#subscribe').hide();
						$.prompt("Ein Fehler trat während Ihres Anmeldungs.");
					}
	            
	        
				
	        }
	   		 );
		}
	}
		


function wrongemail(email) { 
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
	if(reg.test(email))
	{
		return(false);
	}else{
		return(true);
		}
	}


	function visibilite(thingId){
		var targetElement = document.getElementById(thingId) ;
		if (targetElement.style.display == "none"){
			targetElement.style.display = "block" ;
		} else {
			targetElement.style.display = "none" ;
		}
	}
	
	function get_dir(){		
		return "http://www.s382408628.onlinehome.fr/bolle/";
	}
