
function MM_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function displayHafen(div_id, hafen_feld_input_id, hafen_feld_id, ref, top, left)
{   
	var hafenfeld = ""; 
	var parazusatz = "";    
    
    if(top.length == 0 || top==0) top = 20;
    if(left.length == 0) left = 0;
    
    
	if(div_id != "")
	{	
    	hafenfeld = "#" + div_id + " #" + hafen_feld_input_id;
        parazusatz = "&div=" + div_id;
	}
    else
    {
	    hafenfeld = "#" + hafen_feld_input_id;
	}
    
    if(LastKeyCode == 40 ||LastKeyCode == 38)
    {				
        auto_div_change_focus();
    }
    else
    {
        //alert($("#" + div_id + " #" + hafen_feld_input_id).val().length);
        if($(hafenfeld).val().length > 2)
        {
            var hafenfeldLeft =  $(hafenfeld).offset().left;   
            //alert($(hafenfeld).offset().left);
            auto_counter = 0;
    
            ajax_transition({"link":"ajax/SearchHarbor.ax.php", "div_id":"OverlayAX", "para_get":"auto_column_id=id&auto_ziel_id="+hafen_feld_id+"&auto_order=name&auto_div=OverlayAX&auto_ziel="+hafen_feld_input_id+"&auto_column=name&auto_table=hafen&ref="+ref+"&auto_suche="+$(hafenfeld).val()+parazusatz});            
            
            $("#OverlayAXBackground").hide();
            
            document.getElementById("OverlayAX").style.position = "absolute";
            
            var styleleft = $(hafenfeld).offset().left;
            
            //Hafen Feld links ausrichten
            if(hafenfeldLeft > 400)
            {
                styleleft = $(hafenfeld).offset().left;                
            }            
            //Hafenfeld rechts ausrichten
            else
            {
                styleleft = 475 + $(hafenfeld).offset().left;
            }
            
            var overlayAXTop = $(hafenfeld).offset().top + 20 + "px";
            
            if(top > 0)
            {
                overlayAXTop = top + "px";
            }
            
            if(left > 0) 
            {
                styleleft = left;    
            }
            
            document.getElementById("OverlayAX").style.top = overlayAXTop;
            document.getElementById("OverlayAX").style.left = styleleft + "px";
            document.getElementById("OverlayAX").style.border = "0px";
            document.getElementById("OverlayAX").style.backgroundColor = "transparent";
        }      
    }
}

function confirmLink(theLink, theSqlQuery)
{
	var confirmMsg  = 'Möchten Sie folgende Aktion wirklich ausführen ? ';
	// Confirmation is not required in the configuration file
	if (confirmMsg == '') {
	return true;
	}
	var is_confirmed = confirm(theSqlQuery);
	if (is_confirmed) {
	theLink.href += '&is_js_confirmed=1';
	}
	return is_confirmed;
} // end of the 'confirmLink()' function

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects
	for(var item in arr) {
	var value = arr[item];
	
	if(typeof(value) == 'object') { //If it is an array,
	dumped_text += level_padding + "'" + item + "' ...\n";
	dumped_text += dump(value,level+1);
	} else {
	dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
	}
	}
	} else { //Stings/Chars/Numbers etc.
	dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}

function pausecomp(millis)
{
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); }
	while(curDate-date < millis);
} 

function LadeInfo() 
{
	if (document.getElementById) 
    {  // DOM3 = IE5, NS6
   		document.getElementById('hidepage').style.visibility = 'hidden';
	}else{
		if (document.layers) 
		{  // Netscape 4
			document.hidepage.visibility = 'hidden';
		}
		else 
		{  // IE 4
			document.all.hidepage.style.visibility = 'hidden';
		}
	}
}


     
function js_calc_returndate()
{
	var offset = 7;
	var sec_offset = offset*60*60*24;
	var departdate = self.document.frm_suche.termin_von.value;

	if(self.document.frm_suche.termin_von.value != 0)
	{
		// Berechnung neues departdate
		var jahr = '';
		var monat = '';
		var tag = '';
		var dot = 0;
		var von = 0;

		dot = departdate.indexOf('.');
		tag = departdate.substr(von,2);
		von = dot+1;

		dot = departdate.indexOf('.',von);
		monat = departdate.substr(von,2);
		monat = parseInt(monat,10)-1;
		von = dot+1;

		dot = departdate.indexOf('.',von);
		jahr = departdate.substr(von,4);
		von = dot+1;

		//alert(tag+" "+monat+" "+jahr+" "+sec_offset);
		//var zeit = Date.UTC(jahr,monat,tag);
		var sec_departdate = new Date(jahr, monat, tag);
		//alert(sec_departdate);
		sec_departdate.setTime(sec_departdate.getTime()+sec_offset*1000);
		//alert(sec_departdate);
		tag = sec_departdate.getDate();
		monat = sec_departdate.getMonth()+1;
		/*if (monat.length == 1)
		{
		monat = '0'+monat;
		}*/
		jahr = sec_departdate.getFullYear();
		//alert(tag+"."+monat+"."+jahr);
		departdate = tag+"."+monat+"."+jahr;

		self.document.frm_suche.termin_bis.value = departdate;
		return true;
	}
	else return false;
}

function js_check_submit_request()
{
	var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').value;
	var kabine_id_checked = document.getElementById('kabine_id_checked').value;
	
	var intChildAge1 = 0;
	var intChildAge2 = 0;
	var intChildAge3 = 0;
	var intChildAge4 = 0;
	var intChildAge5 = 0;
	 
	if(document.getElementById('vkanz_child_Age[1]')) var intChildAge1 = document.getElementById('vkanz_child_Age[1]').value;	
	if(document.getElementById('vkanz_child_Age[2]')) var intChildAge2 = document.getElementById('vkanz_child_Age[2]').value;
	if(document.getElementById('vkanz_child_Age[3]')) var intChildAge3 = document.getElementById('vkanz_child_Age[3]').value;
	if(document.getElementById('vkanz_child_Age[4]')) var intChildAge4 = document.getElementById('vkanz_child_Age[4]').value;
	if(document.getElementById('vkanz_child_Age[5]')) var intChildAge5 = document.getElementById('vkanz_child_Age[5]').value;	
	
	
	//alert(document.getElementByName('booking_categorycode_default')[0].value);
	//alert(document.getElementByName('booking_categorycode_default').checked+" - "+document.getElementByName('booking_categorycode_default').value);
	/*
	var radio = document.getElementByName("booking_categorycode_default[0]");
	alert(radio.value);
	
	for(var i=0;radio[i];i++)
	{
		alert("test"+i);
	    if(radio[i].checked) alert(radio[i].value);
	}
	*/
	//alert(document.frm_preise.booking_categorycode_default.options.selectedIndex);
	//var RadioName = "booking_categorycode_default";
	//alert(getRadioValue(RadioName)+"test");
	
	//alert("end - return - ??!  "+document.getElementById('booking_categorycode_default').options[document.getElementById('booking_categorycode_default').options.selectedIndex]+" und "+vkanz_adults_anz);
	if(		vkanz_adults_anz > 0
		||  intChildAge1 > 0
		||  intChildAge2 > 0
		||  intChildAge3 > 0
		||  intChildAge4 > 0
		||  intChildAge5 > 0
	){
		
		if(kabine_id_checked > 0){
			return true;
		}else{
		    $('#kabine_id_checked').val('');
			alert("Bitte wählen Sie eine Kategorie!");
			return false;
		}
		/*
		//alert(document.getElementById('booking_categorycode_default').options[document.getElementById('booking_categorycode_default').selectedIndex].value);
		if(document.getElementById('booking_categorycode_default').checked == true || !document.getElementById('booking_categorycode_default')){
			return true;
		}else{
			alert("Bitte wählen Sie eine Kabine!");
			return false;
		}*/
	}else{
		alert("Bitte wählen Sie die Anzahl der Reisenden!");
		return false;
	}
	return true;
}

function js_Convert2ASCII(obj)
{
	/*
	if(document.KonvForm.grenz[0].checked == true)
	grz         = 255
	else if(document.KonvForm.grenz[1].checked == true)
	grz         = 127
	else
	grz         = 0;
	*/
	
	
	if( obj.className == 'TinyMCE'){
		//alert('class:'+obj.className);
		//alert('jquery html:'+val.length+'#'+$('#'+obj.id).html());
		
		obj.value 		= $('#'+obj.id).html();
		//obj.innerHTML 	= $('#'+obj.id).html();
		$('#'+obj.id).tinymce().remove();
		//alert('Remove:'+obj.name);
	}
	
	grz         = 255
	
	var val     = obj.value;
	var len     = val.length;
	var newStr  = "";
	//alert('name:'+obj.name+'Val:'+val.length+'#'+obj.value);	
	
	if(obj.name == 'txtContentLangDescDE' && obj.className == 'TinyMCE'){
		//alert(obj.value);
	}
	if(obj.name == 'txtContentLangDescDE' && obj.className == 'TinyMCE'){
	}
	for (i=0;i<len;i++) {
		if (val.charCodeAt(i)>grz || val.charCodeAt(i) == '34' || val.charCodeAt(i) == '39') {		//inkl.  ' und " :)
			newStr = newStr + "&#"+val.charCodeAt(i)+";";
		} else {
			newStr = newStr + val.substr(i,1);
		}
	}
	
	if( obj.className == 'TinyMCE'){
		//if(newStr != '') alert('NEW:'+newStr);
		/*
		if(newStr != '') $('#'+obj.id).html(newStr);	
		obj.innerHTML = newStr;	
		$('#'+obj.id).tinymce().setContent(newStr);
		*/
		/**/
	}
		
	obj.value = newStr;	
}

function js_goToURL2() { //v3.0
	var i, args=js_goToURL.arguments; document.js_returnValue = false;

	for (i=0; i<(args.length-1); i+=2) 	eval(args[i]+".location='"+args[i+1]+"'");
}

function js_goToURL(loc, url) {
	eval(loc+".location='"+url+"'");
}

 
function js_oeffnenAnreise(url)
{
	var anreise = window.open(url,"window","width=650,height=400,scrollbars");
	if (anreise.opener == null)
	{
		anreise.opener=window;
	}
	anreise.opener.name="kreuzfahrtdetail"
}


function js_pleasewait_show()
{
	if(document.getElementById("maindiv")){
		document.getElementById("maindiv").style.display = 'none';
	}
	if(document.getElementById("waitDiv")){
		document.getElementById("waitDiv").style.display = '';
	}
}


function js_preise_calc(url)
{
	
	var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').value;
	var pers_anz = vkanz_adults_anz;
	
	if(document.getElementById('vkanz_child_Age[1]')) var vkanz_child_Age_1 = document.getElementById('vkanz_child_Age[1]').value;
	if(document.getElementById('vkanz_child_Age[2]')) var vkanz_child_Age_2 = document.getElementById('vkanz_child_Age[2]').value;
	if(document.getElementById('vkanz_child_Age[3]')) var vkanz_child_Age_3 = document.getElementById('vkanz_child_Age[3]').value;
	if(document.getElementById('vkanz_child_Age[4]')) var vkanz_child_Age_4 = document.getElementById('vkanz_child_Age[4]').value;
	
	//var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').selectedIndex + 1;
	//var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').selectedIndex + 1;
	var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').value;
	var vkanz_adults_anz = document.getElementById('vkanz_adults_anz').value;
	url = url + '&vkanz_adults_anz=' +  vkanz_adults_anz;
	
	if(document.getElementById('vkanz_child_Age[1]') && pers_anz < 5 && vkanz_child_Age_1 > 0){ 
		url = url + '&vkanz_child_Age[1]=' +  vkanz_child_Age_1;
		pers_anz++
	}

	if(document.getElementById('vkanz_child_Age[2]') && pers_anz < 5 && vkanz_child_Age_2 > 0){ 
		url = url + '&vkanz_child_Age[2]=' +  vkanz_child_Age_2;
		pers_anz++
	}
	if(document.getElementById('vkanz_child_Age[3]') && pers_anz < 5 && vkanz_child_Age_3 > 0){ 
		url = url + '&vkanz_child_Age[3]=' +  vkanz_child_Age_3;
		pers_anz++
	}
	if(document.getElementById('vkanz_child_Age[4]') && pers_anz < 5 && vkanz_child_Age_4 > 0){ 
		url = url + '&vkanz_child_Age[4]=' +  vkanz_child_Age_4;
		pers_anz++
	}
	
	
    http_request = false;
    if (window.XMLHttpRequest) { 
    // default
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
        }
    } else if (window.ActiveXObject) { 
    // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        return false;
    }
    http_request.onreadystatechange = js_preise_calc_draw;
    http_request.open('GET', url, true);
    http_request.send(null);
	
    return true;
}


function js_preise_calc_draw() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			js_preise_calc_show();
			document.getElementById("preise_calc").innerHTML=http_request.responseText;
		}
	}
}


function js_preise_calc_hide()
{
	/*HIDE DEFAULT PREISE*/
	if(document.getElementById('preise_wait')){
		document.getElementById('preise_wait').style.display = '';
	}
		//document.getElementById('preise_wait_img').style.display = '';
		//document.getElementById('preise_calc').style.display = 'none';
	
}

function js_preise_calc_show()
{
	/*HIDE DEFAULT PREISE*/
	if(document.getElementById('preise_wait')){
		document.getElementById('preise_wait').style.display = 'none';
	}
		//document.getElementById('preise_calc').style.display = '';
		//document.getElementById('preise_wait_img').style.display = 'none';
}

var LastKeyCode = "";
function GetLastKeyCode(Ereignis) 
{
	if (!Ereignis)
	{
		Ereignis = window.event;
	}
	
	if (Ereignis.which) 
	{
		Tastencode = Ereignis.which;
	} 
	else if (Ereignis.keyCode) 
	{
		Tastencode = Ereignis.keyCode;
	}
	LastKeyCode = Tastencode;
	if(Tastencode == 27){
		if(document.getElementById('OverlayAX')){
			$("#OverlayAX").hide();
		}
		if(document.getElementById('OverlayAXBackground')){
			$("#OverlayAXBackground").hide();
		}
	}
}
document.onkeydown = GetLastKeyCode;


function KFBookingContactdataDisable()
{
 	//$('input').attr("disabled", true);
 	$('#content input[type=text]').attr("disabled", true);
 	$('#content input[type=radio]').attr("disabled", true);
 	$('#content input[type=checkbox]').attr("disabled", true);
 	
 	$('#content select').attr("disabled", true);
 	$('#content textarea').attr("disabled", true);
 	
 	
 	
 	$('#content select').attr("style", 'border:0px;background-color:transparent;color:black;');
 	$('#content textarea').attr("style", 'border:0px;background-color:transparent;color:black;');
 	$('#content input[type=text]').attr("style", 'border:0px;background-color:transparent;color:black;');
 	$('#content input[type=radio]').attr("style", 'border:0px;background-color:transparent;color:black;');
 	$('#content input[type=checkbox]').attr("style", 'border:0px;background-color:transparent;color:black;');

 	/* Ändern der Anreise deaktivieren */
 	$('#AnreiseAddLink').hide();
 	$('#AnreiseSelected img').each(function(){$(this).hide();});
}

function KFBookingContactdataEnable()
{
 	$('#content input').removeAttr("disabled");
 	$('#content select').removeAttr("disabled");
 	$('#content textarea').removeAttr("disabled");
}

function CPBookingContactdataDisable()
{
 	//$('input').attr("disabled", true);
 	$('input[type=text]').attr("disabled", true);
 	$('input[type=radio]').attr("disabled", true);
 	$('input[type=checkbox]').attr("disabled", true);
 	
 	$('select').attr("disabled", true);
 	$('textarea').attr("disabled", true);
 	
 	$('input[type=text]').attr("class", 'small_content');
 	$('input[type=radio]').attr("class", 'small_content');
 	$('input[type=checkbox]').attr("class", 'small_content');
 	$('select').attr("class", 'small_content');
 	$('textarea').attr("class", 'small_content');
 	
 	$('input[type=text]').attr("style", 'border:0px;background-color:transparent;');
 	$('input[type=radio]').attr("style", 'border:0px;background-color:transparent;');
 	$('input[type=checkbox]').attr("style", 'border:0px;background-color:transparent;');
 	$('select').attr("style", 'border:0px;background-color:transparent;');
 	$('textarea').attr("style", 'border:0px;background-color:transparent;');
 	
 	/* Ändern der Anreise deaktivieren */
 	$('#AnreiseAddLink').hide();
 	$('#AnreiseSelected img').each(function(){$(this).hide();});
}

function CPBookingContactdataEnable()
{
 	$('input').removeAttr("disabled");
 	$('select').removeAttr("disabled");
 	$('textarea').removeAttr("disabled");
}


function GetJavaScriptCode(scripts)
{
	var script = "";
	if(scripts != '')	
	{	
		scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
       	                         if (scripts !== null) script += arguments[1] + '\n';
        	                        return '';});
	}
	return script;
	
}



function ModTableSortable(axDivID, axTableID){
	if(bContentListSort == '0'){
	    $("#"+axDivID+" #"+axTableID+" tbody tr input").mousedown(function (e) {
   			e.stopPropagation();
		});
		return false;
	}
	var mouseX, mouseY, lastX, lastY = 0;
	$().mousemove(function(e) { mouseX = e.pageX; mouseY = e.pageY; });	
	var need_select_workaround = typeof $(document).attr("onselectstart") != "undefined";
	
	$("#"+axDivID+" #"+axTableID+" tbody tr").live("mousedown", function (e) {
				if(bContentListSort == '0') return false;
	lastY = mouseY;         
	var tr = $(this);
	tr.fadeTo("fast", 0.2); 
	
	$("tr", tr.parent() ).not(this).mouseenter(function(){
		if(bContentListSort == '0') return false;
		
	    if (mouseY > lastY) {
	            $(this).after(tr);
	    } else {
	            $(this).before(tr);
	    }        
	    lastY = mouseY;
	});
	
	$("body").mouseup(function () {        
		if(bContentListSort == '0') return false;
	   tr.fadeTo("fast", 1);           
	   $("tr", tr.parent()).unbind("mouseenter");           
	   $("body").unbind("mouseup"); 
	   
	if (need_select_workaround)
		$(document).unbind("selectstart"); 
		
  	reorder();
	   
	});
	
	e.preventDefault();
	
	// The workaround for IE based browers
		if (need_select_workaround){
			if(bContentListSort == '0'){			
				return false;
			}else{
		    	$(document).bind("selectstart", function () { return false; });
		    }
		    return false;
		}
	}).css("cursor", "move");
	
		function reorder () {
	        var position = 1;
	        $("#"+axDivID+" #"+axTableID+" tbody tr").each(function () {	
				if(bContentListSort == '0') return false;										            
	            $("td:first input", $(this)).val(position);											            
	            $("td", $(this)).removeClass("td1 td2").addClass( position % 2 ? "td1" : "td2");	
	            //$(this).removeClass("td1 td2").addClass( position % 2 ? "td1" : "td2");											 
	            position += 1;											 
	        });
	    }	
	
	    $("#"+axDivID+" #"+axTableID+" tbody tr input").mousedown(function (e) {
   			e.stopPropagation();
		});
	
	var need_select_workaround = typeof $(document).attr("onselectstart") != "undefined";	 	
}

function generateJqueryAjaxSort(axType, axData, axUrl, axDivID, axAsync, axTableID)
{
	//alert("axtype: "+axType+"   axData: "+axData+"   axDivID: "+axDivID+"   axURL: "+axUrl+"   axAsync: "+axAsync+"   axTableID: "+axTableID);
	if(axType.length == 0) axType = "POST";
	
	$.ajax({
	 	type:axType,								 	
	 	url:axUrl,
	 	data: axData,
	 	async: axAsync,
	 	success: function(text){
	 		$("#"+axDivID).html(text);
	 
			var mouseX, mouseY, lastX, lastY = 0;
			$().mousemove(function(e) { mouseX = e.pageX; mouseY = e.pageY; });	
		 	var need_select_workaround = typeof $(document).attr("onselectstart") != "undefined";

			$("#"+axTableID+" tbody tr").live("mousedown", function (e) {
			lastY = mouseY;         
			var tr = $(this);
			tr.fadeTo("fast", 0.2); 

	        $("tr", tr.parent() ).not(this).mouseenter(function(){
	            if (mouseY > lastY) {
	                    $(this).after(tr);
	            } else {
	                    $(this).before(tr);
	            }        
	            lastY = mouseY;
	        });
	 
	        $("body").mouseup(function () {        
	           tr.fadeTo("fast", 1);           
	           $("tr", tr.parent()).unbind("mouseenter");           
	           $("body").unbind("mouseup"); 
		    if (need_select_workaround)
			$(document).unbind("selectstart"); 
	           reorder();
	        });

	        e.preventDefault();
	 
			// The workaround for IE based browers
			if (need_select_workaround)
			    $(document).bind("selectstart", function () { return false; });
		        return false;
		 
		    }).css("cursor", "move");

			function reorder () {
			        var position = 1;
			        $("table tbody tr").each(function () {											            
			            $("td:first input", $(this)).val(position);											            
			            $("td", $(this)).removeClass("td1 td2").addClass( position % 2 ? "td1" : "td2");	
			            //$(this).removeClass("td1 td2").addClass( position % 2 ? "td1" : "td2");											 
			            position += 1;											 
			        });
			    }	

			    $("#"+axTableID+" tbody tr input").mousedown(function (e) {
				e.stopPropagation();
			});

			var need_select_workaround = typeof $(document).attr("onselectstart") != "undefined";	 	
		} 	
 	});	
}

function Favorite(SeitenURL, SeitenTitel, Kommentar){
  if (window.sidebar)
    {
    /* firefox*/
    window.sidebar.addPanel(SeitenTitel,SeitenURL,Kommentar);
    }
  else if(window.opera && window.print)
    {
    /* opera*/
    var elem = document.createElement('a');
    elem.setAttribute('href',SeitenURL);
    elem.setAttribute('title',SeitenTitel);
    elem.setAttribute('rel','sidebar');
    elem.click();
    }
  else if(document.all)
    {
    /* opera*/
    window.external.AddFavorite(SeitenURL,SeitenTitel);
    }
}
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );
	
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
		
$.widget( "ui.combobox", {
_create: function() {
	var self = this,
		select = this.element.hide(),
		selected = select.children( ":selected" ),
		value = selected.val() ? selected.text() : "";
	var input = this.input = $( "<input>" )
		.insertAfter( select )
		.val( value )
		.autocomplete({
			delay: 0,
			minLength: 0,
			source: function( request, response ) {
				var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
				response( select.children( "option" ).map(function() {
					var text = $( this ).text();
					if ( this.value && ( !request.term || matcher.test(text) ) )
						return {
							label: text.replace(
								new RegExp(
									"(?![^&;]+;)(?!<[^<>]*)(" +
									$.ui.autocomplete.escapeRegex(request.term) +
									")(?![^<>]*>)(?![^&;]+;)", "gi"
								), "<strong>$1</strong>" ),
							value: text,
							option: this
						};
				}) );
			},
			select: function( event, ui ) {
				ui.item.option.selected = true;
				self._trigger( "selected", event, {
					item: ui.item.option
				});
			},
			change: function( event, ui ) {
				if ( !ui.item ) {
					var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
						valid = false;
					select.children( "option" ).each(function() {
						if ( $( this ).text().match( matcher ) ) {
							this.selected = valid = true;
							return false;
						}
					});
					if ( !valid ) {
						// remove invalid value, as it didn't match anything
						$( this ).val( "" );
						select.val( "" );
						input.data( "autocomplete" ).term = "";
						return false;
					}
				}
			}
		})
		.addClass( "ui-widget ui-widget-content ui-corner-left" );

	input.data( "autocomplete" )._renderItem = function( ul, item ) {
		return $( "<li></li>" )
			.data( "item.autocomplete", item )
			.append( "<a>" + item.label + "</a>" )
			.appendTo( ul );
	};

	this.button = $( "<button type='button'>&nbsp;</button>" )
		.attr( "tabIndex", -1 )
		.attr( "title", "Show All Items" )
		.insertAfter( input )
		.button({
			icons: {
				primary: "ui-icon-triangle-1-s"
			},
			text: false
		})
		.removeClass( "ui-corner-all" )
		.addClass( "ui-corner-right ui-button-icon" )
		.click(function() {
			// close if already visible
			if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
				input.autocomplete( "close" );
				return;
			}

			// work around a bug (likely same cause as #5265)
			$( this ).blur();

			// pass empty string as value to search for, displaying all results
			input.autocomplete( "search", "" );
			input.focus();
		});
},

destroy: function() {
	this.input.remove();
	this.button.remove();
	this.element.show();
	$.Widget.prototype.destroy.call( this );
}
});
	

function jsChangeSearchDatepickerBisMinDate(ObjectIDVon, ObjectIDBis){
	
	var dateStart = $("#"+ObjectIDVon).val();
	if(dateStart == '') dateStart = new Date();
	
	$("#"+ObjectIDBis).datepicker("option","minDate", dateStart);
	
	if($("#"+ObjectIDVon).val() == $("#"+ObjectIDBis).val() && $("#"+ObjectIDVon).val() != ''){
		//alert('=');
		var tmp = $("#"+ObjectIDBis).val();
		var tmpres = tmp.split('.');
		
		tmpres[0] = parseInt(tmpres[0]);
		tmpres[1] = parseInt(tmpres[1])+1;
		tmpres[2] = parseInt(tmpres[2]);
		
		var tmpdate =  new Date(tmpres[2], tmpres[1], tmpres[0]);
		
		//alert(tmpres[2]+'_'+tmpres[1]+'_'+tmpres[0]);
		/*$("#"+ObjectIDBis).val(tmpdate.getDate()+'.'+tmpdate.getMonth()+'.'+tmpdate.getFullYear());*/
		$("#"+ObjectIDBis).val('');
		
	}
	return true;
}
		    


