// Make JQuery play nicely with other js libraries
// Necessary because of the Google dealer map which uses Prototype
$j = jQuery.noConflict();


// Facebook click
function fbs_click() { 
	u=window.location.protocol + "//" + window.location.host + "" + location.pathname;
	t=document.title;	
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	//_gaq.push(['_trackEvent', "DEL", "Facebook", GetLeasingDetailsForGoogleAnalytics()]);	
	return false;
}

// Twitter click
function twit_click() { 
	u=window.location.protocol + "//" + window.location.host + "" + location.pathname;
	t=document.title;
	window.open('http://twitter.com/home?status=' + t + ' '+encodeURIComponent(u));
	//_gaq.push(['_trackEvent', "DEL", "Twitter", GetLeasingDetailsForGoogleAnalytics()]);	
	return false;
}


//*** Javascript til forside clientside validering***//
function validateNyhederForm() {
	x = document.form1;
	at = x.Name.value
	
	if (at == '') {
		alert('Husk at udfylde dit navn.');
		x.Name.focus();
		return false;
	}

	if (x.Email.value == "") {
		alert("Husk at udfylde din email-adresse.");
		x.Email.focus();
		return false;
	}

	if (x.Email.value.indexOf("@") == -1) {
		alert("Den angivne email-adresse er ikke gyldig.");
		x.Email.focus();
		return false;
	}
}



$j(document).ready(function() {

	// Header replacements
	function replaceFonts () {
		Cufon.replace('h1', { fontFamily: 'skoda' });
		Cufon.now();
	}


	// Prepare the menus
	function prepareMenus(){
		
		//Mainmenu
		$j("#mainmenu li:has('ul')").hover(
			function (){
				$j(this).addClass("open");
			},
			function (){
				$j(this).removeClass("open");
			}
		);
		
		//Modelmenu
		$j("#modelmenu li:has('ul')").hover(
			function (){
				$j(this).addClass("open");
			},
			function (){
				$j(this).removeClass("open");
			}
		);
	}

	//.....................................................................

	// Set class js-enabled on body, to allow for unobtrusive enhancements
	//$j("body").addClass( "js-enabled" );

	// Prepare the menus
	prepareMenus();
	
	// Cufon header replacement
	replaceFonts();
});

