$(window).bind("unload", function() {});
var ajax_load="<div style='text-align:center;width:490px;height:300px'><img src='ximg/loading.gif' alt='loading...' /></div>"; 

function flashOrt(cUp,oUp){
	$('#main_content').html(ajax_load)
	$.ajax({
		   url :'flashort.php',
		   data : { cUp : cUp , oUp : oUp },
		   type : "GET",
		   contentType: "application/json;charset=utf-8",
		   success : function(data){ $('#main_content').html(data) }
		   });
		   
	$.cookie('cUp',cUp);
	$.cookie('oUp',oUp);
	setLand(cUp);
}
function setLand(cUp){
	$('select.land option:contains("'+cUp+'")').attr('selected','selected');
	$('select.land').change();
	
}

function setOrt(oUp){
	$('select.ort option:contains("'+oUp+'")').attr('selected','selected');
	$.get('setmail.php',{ lan : 'site' , loc : $(this).val() });
}

/*function setLanguage(){
	$('#Sprache_des_Fahrers').html("<option value=''>Bitte wählen Sie</option><option value='"+$.cookie('language')+"'>"+$.cookie('language')+"</option><option value='Englisch'>Englisch</option>");
}*/

$(document).ready(function() {	
	$(document).pngFix(); 
	$.locar=$.loc.split("X");				
	
	$('.hide').hide();
	
$('img.hover').live('hover',function(){
	$(this).imH();
	 }).each(function(){
	 	$(this).preLoad();
	 });
		

$.url=window.location.href;
var urlAr=$.url.split('/');
$.lanUp="/"+urlAr[urlAr.length-2]+"/";

$('a.lanchange').each(function(){
		 var newrl= $.url.replace($.lanUp,"/"+$(this).attr('href')+"/");
		$(this).attr('href',newrl);
										 });

$('.top').live('click',function(){
		$('html, body').animate({scrollTop:0}, 'slow');
        return false;
});

$('#ort_form').hide();


flashembed('map', {
	src: 'karte.swf',
	wmode: 'transparent',
	onFail: function() {
		$('#ort_form').show();
		$('#map').css('background-image','url(ximg/map_placeholder.jpg)');
	}
});

$("a.fancybox").fancybox({
 'padding' : 0
 });

$('img.uu_schrift').wrap("<div class='uu_schrift_wrapper' />");
$('div.uu_schrift_wrapper').append("<img class='top' src='ximg/uuschrift_top.png' alt='Top' />");

$(".scroll-pane").jScrollPane({
   'scrollbarMargin' : 16,
   'scrollbarWidth' :12
 });


$('.news_menu_ob').click(function(){
	var getVar=$(this).attr('id');
	$('.news_left').html(ajax_load).load('returntext.php',getVar,function(){}).css('padding-top','50px');
								  });
$('#ort_wrapper').hide();


$('select.land').load("returnchildren.php","lan=site&loc=0X6", function(){								
		setLand($.cookie('cUp'));
																		});

$('select.land').change(function(){
if($(this).val().length>2){
		$('#ort_wrapper').show();
		var cUp=$('option[value='+$(this).val()+']').html();
		if(cUp!==$.cookie('cUp')){
		$.cookie('cUp',cUp);
		$.cookie('oUp',"--");
		}
		$('select.ort').load("returnchildren.php","lan=site&loc="+$(this).val(), function(){
		setOrt($.cookie('oUp'));
		var lans=$.cookie('lang').split(',');
		var ostr="";
		for(var i=0;i<lans.length;i++){
			var lanup=lans[i];
			ostr+="<option value='"+lanup+"'>"+lanup+"</option>";
		}
			$('#Language_of_the_driver').html("<option value=''>Please select</option>"+ostr+"<option value='English'>English</option>");
		
																		});
	}
});


$('select.ort').change(function(){
	if($(this).val().length>0){
		var oUp=$('option[value='+$(this).val()+']').html();
		$.cookie('oUp',oUp);
		if($(this).attr('id')!=="aOrt"){
		$('#main_content').html(ajax_load).load('showort.php',"lan=site&loc="+$(this).val());
		}
		$.get('setmail.php',{ lan : 'site' , loc : $(this).val() });
	}
});
$('input.hp').hide();



$('.send').click(function(){
		$.send=true;
		$('#aLand option').each(function(){
			$(this).val($(this).text());
		});
		
		$('#aOrt option').each(function(){
			$(this).val($(this).text());
		});
		
		
		$('.form_in').each(function(index){
		if($(this).attr('name').indexOf('*')>0){
		  if($(this).val().length<2){
			$.send=false;
			$(this).css("background","#03036a");
		}else{
			$(this).css("background","#000");
		}
			}
		  });
		var hp=$('input.hp').val()+"";
	if(hp.length>5){
		$.send=false;
	}
	if($.send){
		$('form').submit();
	}else{
		alert("Please fill in the required fields..");
	}
	 });

$('.loschen').click(function(){
		$('input').val("");
		$('textarea').val("");
		$('select').val(0);
});

$('input.clear').click(function(){
	if($(this).hasClass('clear')){
		$(this).removeClass("clear");
		$(this).val("");
	}
});

/*$('.drucken').click(function(){
		 var printWindow =  window.open('','PrintWindow');
		 var style="<style>ol.forms { float: left; list-style: none; width: 100%; font-size:11px ; font-family:Verdana, Helvetica, Arial, sans-serif;} ol.forms li { clear: both; float: left; margin: 0 0 10px; width: 100%; list-style-image:none} ol.forms li.seperator{background:url(../ximg/form_seperator.png) no-repeat ; margin: 5px 0px 5px 0px}</style>";
    var html = '<html><head><title>Anfrage</title>'+style+'</head><body><div id="form">' + $('#anfrage_form').html() + '</div></body></html>';
   printWindow.document.open();
    printWindow.document.write(html);
	//printWindow.print();
    printWindow.document.close();
	//printWindow.close();
							 });
*/

$('.drucken').click(function(){
			 $('#anfrage_form').printElement({
					printMode:'popup' ,
					pageTitle:'Eurolimousine - Anfrage',
					overrideElementCSS:[
						'xcss/print.css',
						{ href:'xcss/print.css',media:'print'}]
					});
							 });
	

});

