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 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('','popupWindowName1','status=no,width='+(_width+20)+',height='+(_height+20)+',screenX=50,screenY=50,left=50,top=50');
    window_handle.document.write('<html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-2">'+
        '<title>Biuro Podró¿y Horizon Travel</title>'+
        '<style type="text/css">'+
        'BODY { font-family: Arial, Helvetica, Sans-serif; color: #000080; '+
        'font-size: 11px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; '+
        'background: #FFFFFF; } '+
        'A {text-decoration: none;} A:LINK {color: #000080;} '+
        'A:ACTIVE {color: #000000; text-decoration: underline;} A:HOVER {color: #000000; text-decoration: underline;} '+
        'A:VISITED {color: #000080;}'+
        '</style>'+
        '</head><body><center>'+
        '<img src="'+_url+'" width="'+_width+'" height="'+_height+'"><br><Br>'+
        '[<a href="javascript:window.close();">Zamknij okno</a>]'+
        '</center></body></html>');
}



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;
}
