
window_handle = null;

function open_popup_window(_url,_width, _height) {
    if (window_handle) window_handle.close();
    if (_width<1) { _width = 300; }
    if (_height<1) { _height = 300; }
    window_handle = window.open(_url,'popupWindowName1','status=no,width='+(_width+20)+',height='+(_height+20)+',screenX=50,screenY=50,left=50,top=50');
}

function openTest(numer) {
    openInWindow('http://www.hards.pl/tester/index.php?test_id='+numer,700, 500);
}

function open_popup_window_new(_url,_width, _height) {
    if (_width<1) { _width = 300; }
    if (_height<1) { _height = 300; }
    window.open(_url,'','status=no,width='+(_width+20)+',height='+(_height+20)+',screenX=50,screenY=50,left=50,top=50,scrollbars=yes,resizable=yes');
}


function sendToFriend(_abs, article, lang, style) {
    var strona = _abs+'sendToFriend1.php/'+lang+'/'+style+'/'+article;
    var width = 350;
    var height = 270;
    var wzwin = null;
    if (navigator.appName == "Microsoft Internet Explorer") {
        wzwin = window.open(strona, '', "toolbar=no,menubar=no,scrollbars=auto,resizable=yes,status=no,location=no,directories=no,fullscreen=no,titlebar=no,width="+width+",height="+height);
    } else {
        wzwin = window.open(strona, 'Poleæ artyku³', "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,innerWidth="+width+",innerHeight="+height);
    }
    wzwin.focus();
}

function isdigit(s) {
    for(var i=0;i<s.length;i++) {
        if (s.charAt(i)<'0'||s.charAt(i)>'9') {
            return false;
        }
    }
    return true;
}

function isNipValid(s) {
    var mn = [6,5,7,2,3,4,5,6,7]; var cr = 0;
    if (!s.match(/^[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/gi)) { return false; }
    s = s.substring(0,3)+s.substring(4,7)+s.substring(8,10)+s.substring(11,13);
    for(var i=0;i<mn.length;i++) { cr += mn[i]*parseInt(s.charAt(i),10); }
    cr%=11; cr=(cr==10?0:cr);
    return (cr == parseInt(s.charAt(mn.length),10))?true:false;
}

function isRegon9Valid(s) {
    var mn = [8,9,2,3,4,5,6,7]; var cr = 0;
    if (!s.match(/^[0-9]{9}$/gi)) { return false; }
    for(var i=0;i<mn.length;i++) { cr += mn[i]*parseInt(s.charAt(i),10); }
    cr%=11; cr=(cr==10?0:cr);
    return (cr == parseInt(s.charAt(mn.length),10))?true:false;
}

function isZipValid(s) {
    return (s.match(/^[0-9]{2}(-)?[0-9]{3}$/gi));
}

function jstrim(s) {
    return s.replace(/(^\s+)|(\s+$)/g, "");
}

function isEmailValid(emailstring) {
	if (!emailstring.match(/^[a-z0-9+]{1}[a-z_0-9-\.]*@[a-z0-9]{1}[a-z0-9-]*(\.[a-z0-9]{1}[a-z0-9-]*)+$/gi)) {
		return false;
	}
	return true;
}

function gotoThread( id ){
	window.document.location.href="http://www.hards.pl/page.php/1/0/helpdesk/new-"+id+"/";
	
}

function preload(img)
{
  var a=new Image(); a.src=img; return a;
}

