var popUp; 
var firstLoad = true;
var drop2 = null;
var drop3 = null;

function SetDate(formName, id, newDate, postBack) {
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}		
function openBild(url,w,h) {
	window.open(url,'Bild','width=' + w + ',height=' + h ); 
}
function openPanorama(url) {
	window.open(url,'Panoramabild','width=480,height=450');
}
function openCalendar(url) {
	window.open(url,'Kalender','width=350,height=340,left=100,top=150');
}
function openVermieter(url) {
	window.open(url,'Vermieter','width=790,height=580,left=100,top=150,scrollbars=yes');
}	
function printWindow() {
	window.print();
}
function GS2_ActiveDetailsTabChanged(index) {
    var ullist=$get('gs2maintab').getElementsByTagName("li");
    for (var i=0; i<ullist.length; i++)
        ullist[i].className="";  //deselect all tabs
    ullist[index].className="selected";  //highlight currently clicked on tab
    var divlist=$get('gs2maincontent');
    for (var i=0; i<divlist.childNodes.length; i++)
        divlist.childNodes[i].style.display = "none";  //hide all tabs
    divlist.childNodes[index].style.display = "block";
    if (index == 2 && firstLoad){ LoadMyMap(); firstLoad=false;}
}
function _GS2FillOrte1(list, control, control1) {   
    var drop1 = $get(list);
    var option = drop1.options[drop1.selectedIndex]; 
    drop3 = $get(control1);
    if (drop3 != null) drop3.disabled = 'disabled'
    drop2 = $get(control);
    CoreWebService.FillOrt1(option.value, _GS2FillDrop2OnSucceeded);
}
function _GS2FillOrte2(list, control, control1) {   
    var drop1 = $get(list);
    var option = drop1.options[drop1.selectedIndex]; 
    drop3 = $get(control1);
    if (drop3 != null) drop3.disabled = 'disabled'
    drop2 = $get(control);
    CoreWebService.FillOrt2(option.value, _GS2FillDrop2OnSucceeded);
}
function _GS2FillDrop2OnSucceeded(result) {
    var list = drop2; 
    // *** Clear the list first
    for (x=list.options.length-1; x > -1; x--) {
        list.remove(1);
    }
    for (i=0;i<result.length;i++) {
        var option = document.createElement("option");
        option.text = result[i];
        option.value = result[i];
        if ( window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) 
            drop2.add(option);  
        else
            drop2.add(option, null);        
    }    
}
function _GS2ActivateUmkreis(control, control1, control2) {
    var drop1 = $get(control2);
    var drop2 = $get(control);
    var option1 = drop2.options[drop2.selectedIndex]; 
    var option = drop1.options[drop1.selectedIndex]; 
    drop3 = $get(control1);
    if (option1.value == '-1') drop3.disabled = 'disabled'
    else drop3.disabled = '' 
}
