function getXmlHttp(){
	var xmlhttp;
	try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  	}catch (e) {
    	try {
      	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    	}catch (E) {
      		xmlhttp = false;
    	}
  	}
  	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    	xmlhttp = new XMLHttpRequest();
  	}
	return xmlhttp;
}

//---------------------------------------------------------------------
// Function to set a cookie.
//---------------------------------------------------------------------
function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;

    document.cookie =
        name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}
//---------------------------------------------------------------------
// Function to get a cookie.
//---------------------------------------------------------------------
function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
//---------------------------------------------------------------------
// Function to get a cookie.
//---------------------------------------------------------------------
function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
//---------------------------------------------------------------------
// Function to delete a cookie. (Sets expiration date)
//    name - String object containing the cookie name
//---------------------------------------------------------------------
function DeleteCookie (name)
{
    var exp  = new Date();
    var cval = GetCookie (name);

    exp.setTime (exp.getTime() - 1);  // This cookie is history
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}	

/*
function asyncsend(){
	var xmlhttp = getXmlHttp()
	xmlhttp.open('GET', '/xhr/test.html', true);
	xmlhttp.onreadystatechange = function() {
	  if (xmlhttp.readyState == 4) {
	     if(xmlhttp.status == 200) {
	       alert(xmlhttp.responseText);
	     }
	  }
	};
	xmlhttp.send(null);
}
*/

function setradfield(idfrad, valrad){
	if (valrad){
		document.getElementById(idfrad).value = valrad;
	}
}

function submit_form(id){
	  document.getElementById(id).submit();
}

function rsstake(wth){
	var exp  = new Date();
	var xmlhttp = getXmlHttp();
	var no = '';
	var chan = true;
	var data = '/jssec/rssnews?without='+wth+'&nocash='+exp.getTime();
	//alert(data);
	xmlhttp.open('GET', data, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
		   	if(xmlhttp.status == 200) {
		   		response = xmlhttp.responseText;
		   		//alert(response);
		   		if (response){
		   			var obj = eval('(' + response + ')');
		   			var artrss = obj.artrss;
		   			var textblock ='';
		   			if (artrss){
			   			for (key in artrss){
			        		textblock += '<li class="li_news"><a href="'+artrss[key].href+'">'+artrss[key].title+'</a></li>';
			   			}
		   			}
		   			if (textblock){
		   				if (document.getElementById("newsrss").innerHTML == ''){
		   					document.getElementById("newsrss").innerHTML += textblock;
		   				}
		   			}
				}
		   	}
		}else{
			var no=1;
		}
	};
	xmlhttp.send(null);	
}

function bookmark(){
    var title= document.title;
    var url= location.href;
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if( window.opera && window.print ){
    var mbm = document.createElement('a');
	    mbm.setAttribute('rel','sidebar');
	    mbm.setAttribute('href',url);
	    mbm.setAttribute('title',title);
	    mbm.click();
    }
	else if( document.all ) window.external.AddFavorite( url, title);
}

function set_Center_HomePage() {
    try{
        var serverName = 'http://www.cs-security.com.ua/';
        var objSrc = document.getElementById('isHpLayer');
        if(!objSrc) return false;
        var netscapePriv = window.netscape;
        if (netscapePriv && netscapePriv.security && netscapePriv.security.PrivilegeManager && navigator.preference) 
        { //Mozilla
            netscapePriv.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
            navigator.preference("browser.startup.homepage", serverName);
        }
        else
        { //others. Originaly MSIE

                objSrc.setHomePage(serverName);
        }
    }
    catch(e)
    {
        if(window.sidebar) {
        window.sidebar.addPanel('Îõðàííàÿ êîìïàíèÿ ÖÅÍÒÐ ÑÅÐÂÈÑ', serverName, '');
        }
        else
        {
        //alert('Ioeaea: '+e.message);
        }
    }

return false;
}
