var Flash=new Object();Flash.data={};Flash.transferFromCookies=function(){var data=JSON.parse(unescape(Cookie.get("flash")));if(!data){data={};};Flash.data=data;Cookie.erase("flash");};Flash.writeDataTo=function(name,element){element=$(element);var content="";if(Flash.data[name]){content=Flash.data[name].toString().replace(/\+/g,' ');}
element.html(unescape(content));if(content.length>0){element.show();};};var JSON=function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={'boolean':function(x){return String(x);},number:function(x){return isFinite(x)?String(x):'null';},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);});}
return'"'+x+'"';},object:function(x){if(x){var a=[],b,f,i,l,v;if(x instanceof Array){a[0]='[';l=x.length;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a[a.length]=v;b=true;}}}
a[a.length]=']';}else if(x instanceof Object){a[0]='{';for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a.push(s.string(i),':',v);b=true;}}}
a[a.length]='}';}else{return;}
return a.join('');}
return'null';}};return{copyright:'(c)2005 JSON.org',license:'http://www.JSON.org/license.html',stringify:function(v){var f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){return v;}}
return null;},parse:function(text){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g,'')))&&eval('('+text+')');}catch(e){return false;}}};}();var Cookie={set:function(name,value,daysToExpire){var expire='';if(!daysToExpire)daysToExpire=365;var d=new Date();d.setTime(d.getTime()+(86400000*parseFloat(daysToExpire)));expire='expires='+d.toGMTString();var path="path=/"
var cookieValue=escape(name)+'='+escape(value||'')+'; '+path+'; '+expire+';';return document.cookie=cookieValue;},get:function(name){var cookie=document.cookie.match(new RegExp('(^|;)\\s*'+escape(name)+'=([^;\\s]+)'));return(cookie?unescape(cookie[2]):null);},erase:function(name){var cookie=Cookie.get(name)||true;Cookie.set(name,'',-1);return cookie;},eraseAll:function(){var cookieString=""+document.cookie;var cookieArray=cookieString.split("; ");for(var i=0;i<cookieArray.length;++i)
{var singleCookie=cookieArray[i].split("=");if(singleCookie.length!=2)
continue;var name=unescape(singleCookie[0]);Cookie.erase(name);}},accept:function(){if(typeof navigator.cookieEnabled=='boolean'){return navigator.cookieEnabled;}
Cookie.set('_test','1');return(Cookie.erase('_test')==='1');},exists:function(cookieName){var cookieValue=Cookie.get(cookieName);if(!cookieValue)return false;return cookieValue.toString()!="";}};$(document).ready(function(){Flash.transferFromCookies();Flash.writeDataTo('error',$('#error_div_id'));Flash.writeDataTo('notice',$('#notice_div_id'));$("img.photo").lazyload({placeholder:"/images/trans.gif",effect:"fadeIn"});$("#new_photo").validate({rules:{"photo[title]":{required:true,minlength:5},"photo[description]":{required:true,minlength:50}}});$("#new_user").validate({rules:{"user[login]":{required:true,minlength:4},"user[email]":{required:true,email:true},"user[password]":{required:true,minlength:6},"user[password_confirmation]":{equalTo:"#user_password"}},messages:{'user[password_confirmation]':{equalTo:"Please enter the same password in the confirmation field."}}});$('#new_photo').bind('submit',function(){$('#new_photo').append("Please wait while upload is running").highlight();})});function setTZCountDown(month,day,hour,tz){var toDate=new Date();if(month=='*')toDate.setMonth(toDate.getMonth()+1);else if(month>0)
{if(month<=toDate.getMonth())toDate.setYear(toDate.getYear()+1);toDate.setMonth(month-1);}
if(day.substr(0,1)=='+')
{var day1=parseInt(day.substr(1));toDate.setDate(toDate.getDate()+day1);}
else{toDate.setDate(day);}
toDate.setHours(hour);toDate.setMinutes(0-(tz*60));toDate.setSeconds(0);var fromDate=new Date();fromDate.setMinutes(fromDate.getMinutes()+fromDate.getTimezoneOffset());var diffDate=new Date(0);diffDate.setMilliseconds(toDate-fromDate);return Math.floor(diffDate.valueOf()/1000);}
countdown_tz=function(tz){$('#countdown').countdown({until:setTZCountDown(0,'+1',0,tz),format:"HMS"})}
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-2564800-15']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
