function openWindowFE (url, width, height) {
    fenster = window.open(url, "xxl", "width=" + width + ",height=" + height + ",status=no,scrollbars=no,resizable=no");
    fenster.focus();
}

function openWindowMaps(url ) {
    width = 640;
    height = 540;
    window11 = window.open(url, "cpcmsfe", "width=" + width + ",height=" +  height + ",status=no,scrollbars=yes,resizable=yes");
    window11.focus();
}

/*  xxl gallery **/
function openWindowXXL (url) {
    fenster = window.open(url, "xxl", "width=740,height=700,status=no,scrollbars=no,resizable=no");
    fenster.focus();
}

/*  print popup **/
function openWindowPrint(url) {
    fenster = window.open(url, "print", "width=740,height=800,status=no,scrollbars=yes,resizable=yes");
    fenster.focus();
}




/****************  COOKIE FUNCTIONS **************/

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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 eraseCookie(name) {
	createCookie(name,"",-1);
}


/****************  ARRAY FUNCTIONS **************/

function removeArrDuplicate(arr){
    //get sorted array as input and returns the same array without duplicates.
    var result=new Array();
    var lastValue="";
    for (var i=0; i<arr.length; i++){
      var curValue=arr[i];
      if (curValue != lastValue){
          result[result.length] = curValue;
      }
      lastValue=curValue;
     }
    return result;
}



function containsArrValue(a, e) {
	for(j=0;j<a.length;j++)if(a[j]==e)return true;
	return false;
}




function deleArrValue(value, arr){
  for(ccc = 0; ccc < arr.length; ccc++){
      if(arr[ccc] == value){
        arr.splice(ccc, 1);
      }
  }
  return arr;
}



/****************  MISC FUNCTIONS **************/


function resize(breite,hoehe) {	breite = parseInt(breite); hoehe = parseInt(hoehe);	top.window.resizeTo(breite,hoehe);}
 
$(document).ready( function(){
	
	/* On Hover of Camera Image show Topcar */
	
	var zIndex = 10000;
	var imgDiv;
	$(".showImage").hover(			
		function () {

			imgDiv = $(this)
				.parent()
				.find(".topcar")
				.css("zIndex", zIndex--)
				.show();					
		},
		function () {
			imgDiv.hide();
		}		
	);
	
	$(".icon-link").before('<span class="f_cl_link">&raquo;</span> ');


  /* */
	$("form#formlistaction select.select").change( function(){
	   //alert($(this).val());
  });


  	  /* Checkbox 3 Select */

		var tempBox = Array();
		var checkBoxItems =  $("input.aitem");

		checkBoxItems.click(function() {
			
			var items = $(this);
			tempBox.push($(this));
			
			if(tempBox.length>3) {	
				tempBox.shift();
				//remove the old checked values
				checkBoxItems.attr("checked","");
				// fill in the new checked values
				for(i=0; i <= tempBox.length; i++) {
					if(tempBox[i]){
						tempBox[i].attr("checked","checked");
					}
				}
			}			
	});


});



  /*  +++++++++++++++++  */

  function doCompareing(aitem){
    

    aitem_read   = new Array();
    aitem_merged = new Array(); 
    
    tmpx = readCookie('compareing');
    if(tmpx) aitem_read   = tmpx.split(',');

    aitem_merged = aitem;
    if(aitem_read[0]){
        aitem_merged = aitem_read.concat(aitem);
        aitem_merged = removeArrDuplicate(aitem_merged);
    }

    var aitem_str = '';
    for(iii = 0; iii < aitem_merged.length; iii++){
      if(aitem_merged[iii] != ''){
        if(iii > 0) aitem_str += ','; 
        aitem_str +=  aitem_merged[iii];
      }
    }
    createCookie('compareing', aitem_str, 1);    
    
    $("#tabCompareing").css('display','block');
    
    // fancy corners - start
		if(!jQuery.support.style) {
			$("a.cornerfg").each(function(index) {
				cornerElem = $(this).find("b.corner");
				cornerElem.width($(this).width());		
			});
		}	
		$("b.inactive").css("background", 'none');
		$("b.corner").css("background", 'none');
    // fancy corners - end 
  }



  function doParking(aitem){
            aitem_read   = new Array();
            aitem_merged = new Array(); 
            
            tmpx = readCookie('parking');
            if(tmpx) aitem_read   = tmpx.split(',');

            aitem_merged = aitem;
            if(aitem_read[0]){
                aitem_merged = aitem_read.concat(aitem);
                aitem_merged = removeArrDuplicate(aitem_merged);
			}

            var aitem_str = '';
            for(iii = 0; iii < aitem_merged.length; iii++){
              if(aitem_merged[iii] != ''){
                if(iii > 0) aitem_str += ','; 
                aitem_str +=  aitem_merged[iii];
              }
            }
            createCookie('parking', aitem_str, 1);
            $("#tabParking").css('display','block');
            
            // fancy corners - start
        		if(!jQuery.support.style) {
        			$("a.cornerfg").each(function(index) {
        				cornerElem = $(this).find("b.corner");
        				cornerElem.width($(this).width());		
        			});
        		}	
        		$("b.inactive").css("background", 'none');
        		$("b.corner").css("background", 'none');
            // fancy corners - end             
  }

	/* Gallery Search */

	function gal_show(layerID){
	    document.getElementById(layerID + '-').style.display = "block";
	    document.getElementById(layerID ).style.display = "none";
	}

	function gal_hide(layerID){
		document.getElementById(layerID + '-').style.display = "none";
		document.getElementById(layerID ).style.display = "block";
	}


	$(document).ready( function(){	
	
		if(!jQuery.support.style) {
			$("a.cornerfg").each(function(index) {
				cornerElem = $(this).find("b.corner");
				cornerElem.width($(this).width());		
			});
		}	
		$("b.inactive").css("background", 'none');
		$("b.corner").css("background", 'none');
	
		/* Same Height Columns on Typ3 Search */
		if($("td.col-2-check").html()) {		
			$(".searchTerms").css('height', $("td.col-2-check").height()+10);
		}
	
	});
