﻿var urlSelect = null;

function navigate() {
var url = urlSelect.value;
if(url != "empty" && url.length > 0) {
window.open(url);
}
}

function fullScreen(url)
{
var windowprops = "top=0,left=0,resizable=no,width=" + screen.width + ",height=" + screen.height + ",fullscreen=yes,scrollbars=auto";
window.open(url, "popupPage", windowprops);
}

function keyboardSubmit(e, buttonid){
var keycode;
var bt = document.getElementById(buttonid);

if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;

if (keycode == 13) {
if (null != bt && (typeof bt == 'object')) {
        
if (bt.dispatchEvent && (typeof bt == 'object') && typeof(bt.click) == 'undefined') 
eval(bt.getAttribute('href'));           
else 
bt.click();
}
return false;
} 
}

function enableValidatorsBoolean(id,ctrls,bool)
{
var source = document.getElementById(id);

if((source != undefined && ctrls != undefined) && (source.type == "checkbox" || source.type == "radio"))
for (var i=0; i<ctrls.length; i++)
ValidatorEnable(document.getElementById(ctrls[i]),(source.checked == bool));
}

function writeCookie(name,value,days)
{
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        expires = "; expires="+date.toGMTString();
    }
    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) {
    document.cookie = name + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/";
}


function addClickFunction(id) {
    var b = document.getElementById(id);
    if (b && typeof(b.click) == 'undefined') 
    b.click = function() {
    var result = true; 
    if (b.onclick) result = b.onclick();
        if (typeof(result) == 'undefined' || result) { eval(b.getAttribute('href')); }
    }
}

/* BEGIN: ILocationService */
function AssignAutoCompleteToControl(service, id, language) {
    $("input#" + id).autocomplete(autoCompleteUrl + service,
     {
         dataType: 'json',
         parse: function(data) {
             var rows = new Array();
             for (var i = 0; i < data.length; i++) {
                 rows[i] = { data: data[i], value: data[i], result: data[i] };
             }
             return rows;
         },
         formatItem: function(row, i, n) {
             return row
         },
         extraParams: {
             contextKey: language,
             count: 200
         },
         delay: 100,
         minChars: 2         
     });
}
/* END: ILocationService */



function urlredirect(url) {
    if ($.browser.msie)
        url.replace("&", "&amp;");
    window.location = url;
}

function toggle(id, hplId, showDescription, hideDescription) {
    var tr = document.getElementById(id);
    var hpl = document.getElementById(hplId); ;
    if (tr == null) { return; }
    if (tr.style.display == 'none') {
        hpl.innerText = showDescription;
    }
    else {
        hpl.innerText = hideDescription;
    }
    var bExpand = tr.style.display == '';
    tr.style.display = (bExpand ? 'none' : '');
}

function appendChild(node, text) {
    if (null == node.canHaveChildren || node.canHaveChildren) {
        node.appendChild(document.createTextNode(text));
    } else {
        node.text = text;
    }
}


