//common js functions
//version 4.6

//this page should never load inside of another frame
if (top != self) top.location = self.location;

//cookie enable test and params remember in cookies
document.cookie = "t=1; path=/";
if (!document.cookie) {
}else{
    remember_in_cookie();
}


function checkmail(sbuf){
    // 0=correct, 1=wrong, 2=empty
    if(sbuf!="") {
        re=/(\.@)|(^[\.\-]{1})|(\.\-\.+)|(@\.\-)|(@.*_)/;
        result = re.test(sbuf);
        if(!result) {
            re=/^[(\w)\.\-]+[@]{1}[(\w)\.\-]+[\.\-]{1}[^(\d\W|_|\.\-)]{2,6}$/;
            result = re.test(sbuf);
            if(!result)
                return 1;
            return 0;
        }
        return 1;
    }
    return 2;
}

function jstrim(sbuf) {
    //trim left and right
    if( sbuf !="") {
        sbuf = sbuf.replace(/^\s+/gi, '');
        sbuf = sbuf.replace(/\s+$/gi, '');
    }
    return sbuf;
}

function goredir(_this){
    if(_this.options[_this.selectedIndex].value!='') location.href=_this.options[_this.selectedIndex].value; else _this.selectedIndex=0;
}

function add2favorites() {
    if (document.all){
        window.external.AddFavorite(location.href, document.title);
    }else{
        alert("Press [Ctrl+D], [Ctrl+F], for Opera - [Ctrl+T]");
    }
}

function prnt(str){
    document.write(str);
}

function iif(bool, valtrue, valfalse){
    return bool ? valtrue : valfalse;
}

function send2friend(){
    document.location.href="mailto:?subject=Fwd:["+document.location.href+"]-"+document.title.replace(/\s+/gi, '_')+"&body="+escape(top.parent.location.href);
}

function usual_version(){
    var _url = document.location.href.replace(/txt.shtml|pda.shtml/gi, '');
    document.write('<p class=""dt""><a href=""'+_url+'"">'+_url+'</a></p>');
}


function win_open(){
    if (arguments.length==1) {
        window.open(arguments[0]);
    }
    if(arguments.length==2) {
        window.open(arguments[0], arguments[1]);
    }
    if(arguments.length>=3) {
        window.open(arguments[0], arguments[1], arguments[2]);
    }
}
