var opera=navigator.userAgent.indexOf("Opera")>=0?true:false;var chrome=navigator.userAgent.indexOf("Chrome")>=0?true:false;var ie=document.all&&!opera?true:false;var dom=document.getElementById?true:false;function getStyle(itemID){if(dom)return document.getElementById(itemID);else if(ie)return document.all[itemID]}
function selectFolder(folderID){folder=cookies.readCookie(folderID);swFolder(folderID,folder?"none":"block");if(folder)cookies.deleteCookie(folderID);else cookies.saveCookie(folderID,1)}function swFolder(folderID,value){getStyle(folderID).style.display=value}function swDisplay(folderID){getStyle(folderID).style.display=getStyle(folderID).style.display=="none"?"":"none"}var clWidth=ie?"document.body.clientWidth":"window.innerWidth";var clHeight=ie?"document.body.clientHeight":"window.innerHeight";
function onLoadHandler(){clWidth=eval(clWidth);clHeight=eval(clHeight)}function isEmpty(s){if(s!=null){em=s.replace(/[\t\r\n ]*/g,"");return s==null||s==""||em.length==0}}var ql={login:0,pass:0};function checkLoginFields(){f=document.qlForm;return!isEmpty(f.login.value)&&!isEmpty(f.pass.value)}function doLogin(){qf=document.qlForm;qf.login.value=document.ql1.login.value;qf.pass.value=document.ql2.pass.value;qf.remember.value=document.ql2.remember.checked?1:0;if(checkLoginFields())qf.submit()}
function ow(url,name,w,h,center,scrollbars){if(url)url=unescape(url);eval("if(typeof win_"+name+" != 'undefined') win = win_"+name+"; else win = false;");if(opera&&win){win.close();win=false}if(!win||win.closed){xy="";if(center){x=(screen.availWidth-w)/2;y=(screen.availHeight-h)/2;xy=",top="+y+",left="+x}if(chrome)win=window.open(url,name,"toolbar=0,status=0,resizable=0,scrollbars="+(scrollbars?1:0)+",width="+w+",height="+h+xy).blur();else win=window.open(url,name,"toolbar=0,status=0,resizable=0,scrollbars="+
(scrollbars?1:0)+",width="+w+",height="+h+xy);eval("win_"+name+" = win;")}else{win.focus();if(url&&win.location.pathname+win.location.search!=url)win.location=url}}function textCounter(fieldId,counterId,maxlimit){var textarea=$("#"+fieldId);var counter=$("#"+counterId);textarea.bind("keyup",function(){var length=textarea.attr("value").length;var value=textarea.attr("value");if(length>maxlimit)textarea.attr("value",value.substring(0,maxlimit));else counter.text(maxlimit-length)})}
function disableButtonIfEmpty(fieldId,buttonId){var field=$("#"+fieldId);var button=$("#"+buttonId);var handler=function(){if(field.attr("value").length==0)button.attr("disabled","disabled");else if(button.attr("disabled"))button.removeAttr("disabled")};handler();field.bind("change keyup",handler)}
with(DisableButtonIfEmpty=function(button){this.button=button}){prototype.button;prototype.fields=new Array;prototype.addField=function(field,forbidenValues){var t=this;field.bind("change keyup",function(){t.checkFields()});var fieldArr={field:field,forbiden:forbidenValues};this.fields.push(fieldArr);t.checkFields()};prototype.checkFields=function(){var result=true;for(i in this.fields){var field=this.fields[i]["field"];var forbiden=this.fields[i]["forbiden"];if(field.val().length==0)result=false;
for(value in forbiden)if(field.val()==value)result=false}if(!result)this.button.attr("disabled","disabled");else this.button.removeAttr("disabled")}}function byItemClick(id,text){var conf;if(conf=confirm(text)){document.getElementById("itemID"+id.toString()).onclick=function(){showItem(id)};showItem(id)}return conf}
function buyVideoClick(id,text){var elem=null;var conf;if(conf=confirm(text)){document.getElementById("imgId"+id.toString()).onclick="";document.getElementById("titleId"+id.toString()).onclick="";if(elem=document.getElementById("watchItId"+id.toString()))elem.onclick=""}return conf}function showItem(id){ow("/showitem.php?id="+id+"&sw="+clWidth+"&sh="+clHeight,"viewer",280,120,true)}
function buyItemLink(id,text){var conf;if(conf=confirm(text))document.getElementById("itemLinkID"+id.toString()).href="javascript:showItem("+id.toString()+")";return conf}function showItemStory(id,showVoted){ow("/showitem.php?id="+id+"&sw="+clWidth+"&sh="+clHeight,"viewer",280,120,true);$.get("/ajax/isVotedForEroticStory.php",{id:id},function(data){if(data=="true"&&!showVoted)$("#votestory"+id).show()},"text")}function trim(str){return str.replace(/^\s*([\S\s]*?)\s*$/,"$1")}
(function($){$.fn.initFieldHelpText=function(text){var cleanOnFocus=function(){if($(this).data("emptyValue")==true)$(this).val("")};var fillEmptyInput=function(input,text){if(input.val().length==0){input.data("emptyValue",true);input.val(text)}else input.data("emptyValue",false)};this.each(function(){if(typeof text=="undefined"){var text=$(this).val();$(this).val("")}var fillOnBlur=function(input,text){return function(){fillEmptyInput(input,text)}}($(this),text);$(this).focus(cleanOnFocus);$(this).blur(fillOnBlur);
fillEmptyInput($(this),text)})}})(jQuery);

