﻿function GUIinit(path, filter){
    hoverOut(path)
    if(filter){
        changeFilter(filter);
        $get(filter).checked = true;
    }
}


/*
* Toggle selected system tabs
*/
function toggleSelect(option){
    var voice = $get("imgVoice");
    var data = $get("imgData");
    var View_ddl = View.elm("ddlService");
    if(!voice || !data || !View_ddl) {
        //alert("no ddl");
        return;
	}
	
	//change over images and trigger View part
    if (option==1)
    {
        voice.src = voice.src.replace("voice_off.gif", "voice_on.gif");
        voice.src = voice.src.replace("voice_hover.gif", "voice_on.gif");
        data.src = data.src.replace("data_on.gif", "data_off.gif");
        View_ddl.options.selectedIndex = 0;
        View.onServiceChanged();
    }
    else if (option==2)
    {
        voice.src = voice.src.replace("voice_on.gif", "voice_off.gif");
        data.src = data.src.replace("data_off.gif", "data_on.gif");
        data.src = data.src.replace("data_hover.gif", "data_on.gif");
        View_ddl.options.selectedIndex = 1;
        View.onServiceChanged();
    }
}

function hover(path, option)
{
    var selected = View.elm("ddlService").options.selectedIndex;
    if(option==1 && selected == 1){
        $get('imgVoice').src = path + "/voice_hover.gif";
        $get('imgData').src = path + "/data_on.gif";
    }else if(option==2 && selected==0){
        $get('imgVoice').src = path + "/voice_on.gif";
        $get('imgData').src = path + "/data_hover.gif";
    }        
}

function hoverOut(path) {
    var selected = View.elm("ddlService").options.selectedIndex;
    if(selected==1){
        $get('imgVoice').src = path + "/voice_off.gif";
        $get('imgData').src = path + "/data_on.gif";
    } else if(selected==0) {
        $get('imgVoice').src = path + "/voice_on.gif";
        $get('imgData').src = path + "/data_off.gif";
    }       
}

/*
* Change nidoor/outdoor and opr/pln filters in map
*/

function changeFilter(option){

    if(option == 'IN'){
        View.elm('OUTDOOR').checked = true;     //show indoor
        if(View.elm('OPR').checked == false){
            View.elm('OPR').checked = true;     //show operational
        }
        
        View.onTimeLevelChanged('OPR', 'CHECK');
        View.onCovLevelChanged('OUTDOOR', 'CHECK'); 
    }
    else if(option == 'OUT'){
        View.elm('OUTDOOR').checked = false;    //show outdoor
        if(View.elm('OPR').checked == false){
            View.elm('OPR').checked = true;     //show operational
        }
        
        View.onTimeLevelChanged('OPR', 'CHECK');
        View.onCovLevelChanged('OUTDOOR', 'CHECK');  
    }
    else if(option == 'PLN'){
        View.elm('OUTDOOR').checked = false;    //show outdoor
        if(View.elm('OPR').checked == true){
            View.elm('OPR').checked = false;    //show planned
        }
        
        View.onTimeLevelChanged('OPR', 'CHECK');
        View.onCovLevelChanged('OUTDOOR', 'CHECK');
        //change to pln 
    }
    else{return;}
    
    //var rect = MapApi.getMapRect();
    //alert("URX: " + rect.URX + " URY: " + rect.URY + " LLX: " + rect.LLX + " LLY: " + rect.LLY);
}

/*
* Is image checkbox checked
*/
//function checked(obj){
//    var file = obj.src.substring(obj.src.lastIndexOf("/")+1);
//    if (file.indexOf("_on")>0){
//        return true;
//    }
//    else {
//        return false;
//    }
//}

/*
* Hotlink to make sure fullscreen map shows the same are as the embedded version.
*/
//function openFullscreen(){
//    var width = MapApi.getMapWidthMeter();
//    var rect = MapApi.getMapRect();
//    var x = rect.LLX + ((rect.URX - rect.LLX) / 2);
//    var y = rect.LLY + ((rect.URY - rect.LLY) / 2);
//    window.open("Default.aspx?MapFrame_resizable=true&MapClient_mapCenterXworld=" + x 
//        + "&MapClient_mapCenterYworld=" + y 
//        + "&MapClient_mapWidthWorld=" + width);
//}            
//function print(){
//    if(MapApi){
//        MapApi.printMap()
//    }
//}
//function openHelp(url){
//    window.open(url,"_blank",
//    "toolbar=yes, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400")
//}
    

