
var NajNocleg={WIDGET_DIV_ID:'NAJNOCLEG_WIDGET'};var width=220;NajNocleg.init=function(){document.getElementById(NajNocleg.WIDGET_DIV_ID).innerHTML='<div style="width:'+(width-20)+'px;padding:10px;height:auto;background:#8EACCA url(\'http://najnocleg.pl/widget_bg.gif\') center no-repeat;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;font-size:11px;font-family:Verdana;color:#FFFFFF;text-shadow:#999999 1px 1px;text-align:left;">'+'<div style="font-size:14px;border-bottom:1px solid #AEC4D9;margin:0 0 7px 0;"><b>Porównaj noclegi</b></div>'+'<div id="NajNocleg_msg" style="font-size:11px;color:#FFFFCC;font-weight:bold;display: none"></div>'+'<form id="NajNocleg_form" method="get" action="http://najnocleg.pl/aff/">'+'<div style="margin:7px 0 7px 0;">'+' <label for="NajNocleg_city" style="display:block;margin:0 0 5px 0;"><b>Miejscowość:</b></label>'+' <input id="NajNocleg_city" name="city" type="text" title="Podaj nazwę miejscowości" style="background:#FFFFFF;border:1px solid #FFFFFF;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;width:'+(width-25)+'px;padding:2px 0 2px 0;" />'+'</div>'+'<div style="margin:7px 0 7px 0;">'+' <label for="NajNocleg_dfrom" style="display:block;margin:0 0 5px 0;"><b>Termin:</b></label>'+' od <input id="NajNocleg_dfrom" name="d_from" title="dd-mm-rrrr" type="text" style="background:#FFFFFF;border:1px solid #FFFFFF;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;width:'+(width/2-35)+'px;padding:2px 0 2px 0;" />'+' do <input id="NajNocleg_dto" name="d_to" title="dd-mm-rrrr" type="text" style="background:#FFFFFF;border:1px solid #FFFFFF;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;width:'+(width/2-35)+'px;padding:2px 0 2px 0;" />'+'</div>'+'<div style="margin:7px 0 7px 0;">'+' <label for="NajNocleg_places" style="margin:0 0 5px 0;"><b>Liczba osób:</b></label>'+' <select id="NajNocleg_places" name="places" style="background:#FFFFFF;border:1px solid #FFFFFF;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;padding:2px 0 2px 0;width:'+(width/2-30)+'px;margin:0 0 0 10px;" />'+'  <option value="1">1</option><option value="2" selected>2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="4">4</option><option value="6">6</option>'+' </select>'+'</div>'+'<div style="margin:7px 0 0 0;">'+' <a href="http://www.najnocleg.pl"><img src="http://najnocleg.pl/widget_logo.gif" alt="" style="border:0;vertical-align:middle;" /></a>'+' <input type="submit" value="Szukaj" style="background:#CCCCCC;border:1px solid #CCCCCC;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;font-family:Verdana;font-weight:bold;color:#333333;text-shadow:#FFFFFF 1px 1px;padding:2px 0 2px 0;margin:0 0 0 10px;width:'+(width-130)+'px;" />'+' <input name="aff" type="hidden" value="381" />'+'</div>'+'</form>'+'</div>';NajNocleg.placeholder(document.getElementById("NajNocleg_city"));NajNocleg.placeholder(document.getElementById("NajNocleg_dfrom"));NajNocleg.placeholder(document.getElementById("NajNocleg_dto"));var dateMask=new NajNocleg.Mask("##-##-####");dateMask.attach(document.getElementById("NajNocleg_dfrom"));dateMask.attach(document.getElementById("NajNocleg_dto"));var form=document.getElementById("NajNocleg_form");form.onsubmit=function(){var msg=document.getElementById("NajNocleg_msg");if(this['city'].value==''||this['city'].value==this['city'].title){msg.innerHTML='Podaj nazwę miejscowości';msg.style.display='block';return false;}
else if(!NajNocleg.Validation.isDate(this['d_from'].value)||!NajNocleg.Validation.isDate(this['d_to'].value)){msg.innerHTML='Podany zakres dat jest niepoprawny';msg.style.display='block';return false;}
msg.style.display='none';return true;}}
NajNocleg.placeholder=function(el){if(el){if(el.value==''){el.value=el.title;el.style.color='#777';}
el.onfocus=function(){if(this.value==this.title){el.style.color='#000';this.value='';}}
if(el.captureEvents)el.captureEvents(Event.FOCUS);el.onblur=function(){if(this.value==''){this.value=this.title;}
if(this.value==this.title){el.style.color='#777';}}
if(el.captureEvents)el.captureEvents(Event.BLUR);}}
NajNocleg.IEContentLoaded=function(w,fn){var d=w.document,done=false,init=function(){if(!done){done=true;fn();}};(function(){try{d.documentElement.doScroll('left');}catch(e){setTimeout(arguments.callee,50);return;}
init();})();d.onreadystatechange=function(){if(d.readyState=='complete'){d.onreadystatechange=null;init();}};}
NajNocleg.SafariContentLoaded=function(fn){if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,50);return;}
fn();}
NajNocleg.BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};function _MaskAPI(){this.version="0.4b";this.instances=0;this.objects={};}
MaskAPI=new _MaskAPI();NajNocleg.Mask=function(m,t){this.mask=m;this.type=(typeof t=="string")?t:"string";this.error=[];this.errorCodes=[];this.value="";this.strippedValue="";this.allowPartial=false;this.id=MaskAPI.instances++;this.ref="MaskAPI.objects['"+this.id+"']";MaskAPI.objects[this.id]=this;}
NajNocleg.Mask.prototype.attach=function(o){$addEvent(o,"onkeydown","return "+this.ref+".isAllowKeyPress(event, this);",true);$addEvent(o,"onkeyup","return "+this.ref+".getKeyPress(event, this);",true);}
NajNocleg.Mask.prototype.isAllowKeyPress=function(e,o){if(this.type!="string")return true;var xe=new qEvent(e);if(((xe.keyCode>47)&&(o.value.length>=this.mask.length))&&!xe.ctrlKey)return false;return true;}
NajNocleg.Mask.prototype.getKeyPress=function(e,o,_u){this.allowPartial=true;var xe=new qEvent(e);if((xe.keyCode>47)||(_u==true)||(xe.keyCode==8||xe.keyCode==46)){var v=o.value,d;if(xe.keyCode==8||xe.keyCode==46)d=true;else d=false
if(this.type=="number")this.value=this.setNumber(v,d);else if(this.type=="date")this.value=this.setDateKeyPress(v,d);else this.value=this.setGeneric(v,d);o.value=this.value;}
this.allowPartial=false;return true;}
NajNocleg.Mask.prototype.format=function(s){if(this.type=="number")this.value=this.setNumber(s);else if(this.type=="date")this.value=this.setDate(s);else this.value=this.setGeneric(s);return this.value;}
NajNocleg.Mask.prototype.throwError=function(c,e,v){this.error[this.error.length]=e;this.errorCodes[this.errorCodes.length]=c;if(typeof v=="string")return v;return true;}
NajNocleg.Mask.prototype.setGeneric=function(_v,_d){var v=_v,m=this.mask;var r="x#*",rt=[],nv="",t,x,a=[],j=0,rx={"x":"A-Za-z","#":"0-9","*":"A-Za-z0-9"};v=v.replace(new RegExp("[^"+rx["*"]+"]","gi"),"");if((_d==true)&&(v.length==this.strippedValue.length))v=v.substring(0,v.length-1);this.strippedValue=v;var b=[];for(var i=0;i<m.length;i++){x=m.charAt(i);t=(r.indexOf(x)>-1);if(x=="!")x=m.charAt(i++);if((t&&!this.allowPartial)||(t&&this.allowPartial&&(rt.length<v.length)))rt[rt.length]="["+rx[x]+"]";a[a.length]={"chr":x,"mask":t};}
var hasOneValidChar=false;if(!this.allowPartial&&!(new RegExp(rt.join(""))).test(v))return this.throwError(1,"The value \""+_v+"\" must be in the format "+this.mask+".",_v);else if((this.allowPartial&&(v.length>0))||!this.allowPartial){for(i=0;i<a.length;i++){if(a[i].mask){while(v.length>0&&!(new RegExp(rt[j])).test(v.charAt(j)))v=(v.length==1)?"":v.substring(1);if(v.length>0){nv+=v.charAt(j);hasOneValidChar=true;}
j++;}else nv+=a[i].chr;if(this.allowPartial&&(j>v.length))break;}}
if(this.allowPartial&&!hasOneValidChar)nv="";if(this.allowPartial){if(nv.length<a.length)this.nextValidChar=rx[a[nv.length].chr];else this.nextValidChar=null;}
return nv;}
function qEvent(e){if(window.Event){var isKeyPress=(e.type.substring(0,3)=="key");this.keyCode=(isKeyPress)?parseInt(e.which,10):0;this.button=(!isKeyPress)?parseInt(e.which,10):0;this.srcElement=e.target;this.type=e.type;this.x=e.pageX;this.y=e.pageY;this.screenX=e.screenX;this.screenY=e.screenY;if(document.layers){this.altKey=((e.modifiers&Event.ALT_MASK)>0);this.ctrlKey=((e.modifiers&Event.CONTROL_MASK)>0);this.shiftKey=((e.modifiers&Event.SHIFT_MASK)>0);this.keyCode=this.translateKeyCode(this.keyCode);}else{this.altKey=e.altKey;this.ctrlKey=e.ctrlKey;this.shiftKey=e.shiftKey;}}else{e=window.event;this.keyCode=parseInt(e.keyCode,10);this.button=e.button;this.srcElement=e.srcElement;this.type=e.type;if(document.all){this.x=e.clientX+document.body.scrollLeft;this.y=e.clientY+document.body.scrollTop;}else{this.x=e.clientX;this.y=e.clientY;}
this.screenX=e.screenX;this.screenY=e.screenY;this.altKey=e.altKey;this.ctrlKey=e.ctrlKey;this.shiftKey=e.shiftKey;}
if(this.button==0){this.setKeyPressed(this.keyCode);this.keyChar=String.fromCharCode(this.keyCode);}}
qEvent.prototype.translateKeyCode=function(i){var l={};if(!!document.layers){if(this.keyCode>96&&this.keyCode<123)return this.keyCode-32;l={96:192,126:192,33:49,64:50,35:51,36:52,37:53,94:54,38:55,42:56,40:57,41:48,92:220,124:220,125:221,93:221,91:219,123:219,39:222,34:222,47:191,63:191,46:190,62:190,44:188,60:188,45:189,95:189,43:187,61:187,59:186,58:186,"null":null}}
return(!!l[i])?l[i]:i;}
qEvent.prototype.setKP=function(i,s){this.keyPressedCode=i;this.keyNonChar=(typeof s=="string");this.keyPressed=(this.keyNonChar)?s:String.fromCharCode(i);this.isNumeric=(parseInt(this.keyPressed,10)==this.keyPressed);this.isAlpha=((this.keyCode>64&&this.keyCode<91)&&!this.altKey&&!this.ctrlKey);return true;}
qEvent.prototype.setKeyPressed=function(i){var b=this.shiftKey;if(!b&&(i>64&&i<91))return this.setKP(i+32);if(i>95&&i<106)return this.setKP(i-48);switch(i){case 49:case 51:case 52:case 53:if(b)i=i-16;break;case 50:if(b)i=64;break;case 54:if(b)i=94;break;case 55:if(b)i=38;break;case 56:if(b)i=42;break;case 57:if(b)i=40;break;case 48:if(b)i=41;break;case 192:if(b)i=126;else i=96;break;case 189:if(b)i=95;else i=45;break;case 187:if(b)i=43;else i=61;break;case 220:if(b)i=124;else i=92;break;case 221:if(b)i=125;else i=93;break;case 219:if(b)i=123;else i=91;break;case 222:if(b)i=34;else i=39;break;case 186:if(b)i=58;else i=59;break;case 191:if(b)i=63;else i=47;break;case 190:if(b)i=62;else i=46;break;case 188:if(b)i=60;else i=44;break;case 106:case 57379:i=42;break;case 107:case 57380:i=43;break;case 109:case 57381:i=45;break;case 110:i=46;break;case 111:case 57378:i=47;break;case 8:return this.setKP(i,"[backspace]");case 9:return this.setKP(i,"[tab]");case 13:return this.setKP(i,"[enter]");case 16:case 57389:return this.setKP(i,"[shift]");case 17:case 57390:return this.setKP(i,"[ctrl]");case 18:case 57388:return this.setKP(i,"[alt]");case 19:case 57402:return this.setKP(i,"[break]");case 20:return this.setKP(i,"[capslock]");case 32:return this.setKP(i,"[space]");case 91:return this.setKP(i,"[windows]");case 93:return this.setKP(i,"[properties]");case 33:case 57371:return this.setKP(i*-1,"[pgup]");case 34:case 57372:return this.setKP(i*-1,"[pgdown]");case 35:case 57370:return this.setKP(i*-1,"[end]");case 36:case 57369:return this.setKP(i*-1,"[home]");case 37:case 57375:return this.setKP(i*-1,"[left]");case 38:case 57373:return this.setKP(i*-1,"[up]");case 39:case 57376:return this.setKP(i*-1,"[right]");case 40:case 57374:return this.setKP(i*-1,"[down]");case 45:case 57382:return this.setKP(i*-1,"[insert]");case 46:case 57383:return this.setKP(i*-1,"[delete]");case 144:case 57400:return this.setKP(i*-1,"[numlock]");}
if(i>111&&i<124)return this.setKP(i*-1,"[f"+(i-111)+"]");return this.setKP(i);}
function $addEvent(o,_e,c,_b){var e=_e.toLowerCase(),b=(typeof _b=="boolean")?_b:true,x=(o[e])?o[e].toString():"";x=x.substring(x.indexOf("{")+1,x.lastIndexOf("}"));x=((b)?(x+c):(c+x))+"\n";return o[e]=(!!window.Event)?new Function("event",x):new Function(x);}
NajNocleg.Validation={};NajNocleg.Validation.isDate=function(txtDate){var objDate;var mSeconds;if(txtDate.length!=10)return false;var day=txtDate.substring(0,2)-0;var month=txtDate.substring(3,5)-1;var year=txtDate.substring(6,10)-0;if(txtDate.substring(2,3)!='-')return false;if(txtDate.substring(5,6)!='-')return false;if(year<999||year>3000)return false;mSeconds=(new Date(year,month,day)).getTime();objDate=new Date();objDate.setTime(mSeconds);if(objDate.getFullYear()!=year)return false;if(objDate.getMonth()!=month)return false;if(objDate.getDate()!=day)return false;return true;}
document.write('<div id="'+NajNocleg.WIDGET_DIV_ID+'"></div>');NajNocleg.BrowserDetect.init();switch(NajNocleg.BrowserDetect.browser){case"Explorer":NajNocleg.IEContentLoaded(window,NajNocleg.init);break;case"Safari":NajNocleg.SafariContentLoaded(NajNocleg.init);break;default:document.addEventListener("DOMContentLoaded",NajNocleg.init,false);break}