﻿// JScript File
    var current_browser = check_browser();
    var pwnd;
    
    function check_browser(){
        if (document.layers) return "NS";
        if (document.all) return "IE";
        if (document.getElementById) return "MOZ";
        return "OTHER";
    }
    function refresh_window(){
        if(current_browser=='MOZ'){
            top.resizeBy(1,1);
            top.resizeBy(-1,-1);
        }else if(!document.createPopup){
        }
    }
    function open_window(href, w, h){
        var left = (window.screen.width  - w) / 2;
	    var top  = (window.screen.height - h) / 2;
	    window.open(href, '', 'location=yes,toolbar=yes,status=yes,scrollbars=yes,directories=yes,menubar=yes,resizable=yes,left='+left+',top='+top+',width='+w+'px,height='+h+'px');
	    return false;
    }
    function open_tool_window(href, w, h){
        var left = (window.screen.width  - w) / 2;
	    var top  = (window.screen.height - h) / 2;
	    if(typeof(pwnd) != 'undefined') pwnd.close();
	    pwnd = window.open(href, 'wnd', 'toolbar=no,status=no,scrollbars=auto,directories=no,menubar=no,left='+left+',top='+top+',width='+w+'px,height='+h+'px');
	    pwnd.focus();
	    return false;
    }
    function refresh_frame(id){
        var fr=window.frames[id];
        if(fr){
            fr.location=fr.location; 
        }
    }
    function get_element(id){
        if (id!=''){
	        if (document.getElementById){
		        return document.getElementById(id);
	        } else if (document.all){
		        return document.all[id];
	        }
	    }
	    return false;
    }
    function get_value(id,defval){
        var el=get_element(id);
        if(el){
            return el.value;
        }
        return defval;
    }
    function get_document_element(d,id){
        if (id!=''){
	        if (d.getElementById){
		        return d.getElementById(id);
	        } else if (d.all){
		        return d.all[id];
	        }
	    }
	    return false;
    }
    function set_focus(id){
        var t=get_element(id);
        if(t&&typeof(t.focus)!="undefined"){
            t.focus();
        }
    }
    function set_height(id,h){
        var ctl = get_element(id);
        if(ctl){
            if(ctl.height) ctl.height = h;
            ctl.style.height = h;
        }
    }
    function set_src(id,c1,c2){
        var ctl = get_element(id);
        if(ctl){
            ctl.src=ctl.src.replace(c1,c2);
        }
    }
    function set_class(id, cn){
	    set_ctl_class(get_element(id),cn);
    }
    function set_ctl_class(ctl,cn){
    	if (ctl&&ctl.className){
		    ctl.className = cn;
        }
    }
    function enable_element(id){
        var ctl = get_element(id);
        if(ctl){
            ctl.disabled = false;        
        }
    }
    function disable_element(id){
        var ctl = get_element(id);
        if(ctl){
            ctl.disabled = true;        
        }
    }
    function set_value(id, value){
    	ctl = document.getElementById(id);
	    if(ctl){
	        ctl.value = value;
	    }
    }
    function writit(id, text){
	    ctl = document.getElementById(id);
	    if(ctl){
	        ctl.innerHTML = '';
	        ctl.innerHTML = text;
	    }
	}
	
	
	function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
	}
	function get_cookie(name) 
    {
		var cookie = " " + document.cookie;
		var search = " " + name + "=";
		var setStr = null;
		var offset = 0;
		var end = 0;
		if (cookie.length > 0) 
		  {
			offset = cookie.indexOf(search);
			if (offset != -1) 
			  {
				offset += search.length;
				end = cookie.indexOf(";", offset)
				if (end == -1) 
				  {
					end = cookie.length;
				  }
				setStr = unescape(cookie.substring(offset, end));
			  }
		  }
		return(setStr);
    }