var onMap = false;//If map moves, its true
var onMov = false;//If map moves by orders, its true
var onGsr = false;//If map moves by Google Webservice

var cursel;//Default selected calendar

function getCityInfo(obj){
    var id = document.getElementById(obj).value;
    curCity = city_info[id];
    var latLon = curCity.split(",");
    moveToPos(latLon[0], latLon[1]);
    onMap = false;
    onGsr = false;
}

function gmtRound(hour){
    var h = Math.round(hour,0);
    var m = hour - h;
    m = (m>0)? .5 : .0;
    return h + m;
}

function setAdv(id,fadjr,maghreb,isha){
    if(id == 'calt_custom'){
        document.getElementById("caltp_fadjr").disabled   = false;
        document.getElementById("caltp_maghreb").disabled = false;
        document.getElementById("caltp_isha").disabled    = false;
    }
    else{
        document.getElementById("caltp_fadjr").disabled   = true;
        document.getElementById("caltp_maghreb").disabled = true;
        document.getElementById("caltp_isha").disabled    = true;
    }
    
    document.getElementById("caltp_fadjr").value   = fadjr;
    document.getElementById("caltp_maghreb").value = maghreb;
    document.getElementById("caltp_isha").value    = isha;
    
    document.getElementById("caltype").value = id;
    
    return;
}

function setFont(){
    var obj = document.getElementById('font');
    var fname = obj.options[obj.selectedIndex].innerHTML;
    document.getElementById('prv_sec').style.fontFamily = fname;
}

function setLang(){
    var obj = document.getElementById('lang');
    var lname = obj.options[obj.selectedIndex].value;
    //alert(lname);
    //document.getElementById('prv_sec').style.fontFamily = fname;
}

function setex(elm){
    extrafunc = function(elm){
        srvprev(elm);
    }
}

function srvprev(elm){
    if(elm == "color_a" || elm == null){
        var color_a = document.getElementById('color_a').value;

        document.getElementById('prv_b0').style.backgroundColor  = color_a;
        
        document.getElementById('prv_b2').style.backgroundColor  = color_a;
        
        document.getElementById('prv_b3').style.backgroundColor  = color_a;
        document.getElementById('prv_b3').style.borderLeftColor  = color_a;
        document.getElementById('prv_b3').style.borderRightColor = color_a;
        
        document.getElementById('prv_b4').style.backgroundColor  = color_a;
        document.getElementById('prv_b4').style.borderLeftColor  = color_a;
        document.getElementById('prv_b4').style.borderRightColor = color_a;
        
        document.getElementById('prv_b5').style.backgroundColor  = color_a;
        document.getElementById('prv_b5').style.borderLeftColor  = color_a;
        document.getElementById('prv_b5').style.borderRightColor = color_a;
        
        document.getElementById('prv_b7').style.backgroundColor  = color_a;
        document.getElementById('prv_b7').style.borderLeftColor  = color_a;
        document.getElementById('prv_b7').style.borderRightColor = color_a;
        
        document.getElementById('prv_b8').style.backgroundColor  = color_a;
        document.getElementById('prv_b8').style.borderLeftColor  = color_a;
        document.getElementById('prv_b8').style.borderRightColor = color_a;
        
        document.getElementById('prv_b9').style.backgroundColor  = color_a;
        document.getElementById('prv_b9').style.borderLeftColor  = color_a;
        document.getElementById('prv_b9').style.borderRightColor = color_a;
        
        document.getElementById('prv_citytitle').style.backgroundColor = color_a;
        document.getElementById('prv_citytitle').style.borderColor     = color_a;
    }

    if(elm == "color_b" || elm == null){
        var color_b = document.getElementById('color_b').value;
        document.getElementById('prv_citytitle').style.color = color_b;
    }
    
    if(elm == "color_c" || elm == null){
        var color_c = document.getElementById('color_c').value;
        document.getElementById('prv_untilAzan').style.color = color_c;
    }
    
    if(elm == "color_d" || elm == null){
        var color_d = document.getElementById('color_d').value;
        document.getElementById('prv_remTime').style.color = color_d;
    }
    
    if(elm == "color_e" || elm == null){
        var color_e = document.getElementById('color_e').value;
        document.getElementById('prv_curazan').style.color     = color_e;
        document.getElementById('prv_curazantime').style.color = color_e;
    }
    
    if(elm == "color_f" || elm == null){
        var color_f = document.getElementById('color_f').value;
        document.getElementById('prv_tips').style.color = color_f;
    }
    
    if(elm == "color_g" || elm == null){
        var color_g = document.getElementById('color_g').value;
        document.getElementById('prv_row_0').style.color  = color_g;
        document.getElementById('prv_row_1').style.color  = color_g;
        document.getElementById('prv_row_2').style.color  = color_g;
        document.getElementById('prv_row_3').style.color  = color_g;
        document.getElementById('prv_row_4').style.color  = color_g;
        document.getElementById('prv_brow_0').style.color = color_g;
        document.getElementById('prv_brow_1').style.color = color_g;
        document.getElementById('prv_brow_2').style.color = color_g;
        document.getElementById('prv_brow_3').style.color = color_g;
        document.getElementById('prv_brow_4').style.color = color_g;
    }
    
    if(elm == "color_h" || elm == null){
        var color_h = document.getElementById('color_h').value;
        document.getElementById('prv_arrow').style.backgroundColor  = color_h;
        document.getElementById('prv_arrowb').style.backgroundColor = color_h;
    }
    
    if(elm == "color_i" || elm == null){
        var color_i = document.getElementById('color_i').value;
        document.getElementById('prv_arrow').style.color  = color_i;
        document.getElementById('prv_arrowb').style.color = color_i;
    }
    
    if(elm == "color_j" || elm == null){
        var color_j = document.getElementById('color_j').value;
        document.getElementById('prv_sec').style.backgroundColor = color_j;
    }
}

function changecs(value){
    document.getElementById('ctype').value = value;
}

function changecb(value){
    document.getElementById('cstype_'+ value).checked = true;
    document.getElementById('ctype').value = value;
}

