(function(el,st){(function($){$(document).ready(function(){for(var i=1;7>=i;i++){$('#poke'+i).click(function(event){if(0<Comment.pokeTypeId){el('poke'+Comment.pokeTypeId).className="";}
Comment.pokeTypeId=this.id.substr(4,this.id.length);this.className="selected";});}
$('#limitedtextarea').keyup(function(){Comment.limitText('limitedtextarea','countdown',1000);});$('#limitedtextarea').keydown(function(){Comment.limitText('limitedtextarea','countdown',1000);});});})(jQuery);Comment={opac:0,obol:null,aDiv:null,lDiv:null,rDiv:null,tDiv:null,sDiv:null,uDiv:null,frag:null,obody:null,tArea:null,divId:null,comment:'',commentID:0,captcha:null,count:7,context:0,contextId:0,clickedId:0,pokeTypeId:0,pokeType:'smile',pokeImg:'smile.png',pokePath:'',ajaxPath:'/ajaxpages/',photoCat:'',lastob:'',lastop:0,ecollapse:function(t,id){for(i=1;i<t;i++){if(st("greeting"+i).display=='none'){jQuery("#greeting"+i).css('display','');el(id).innerHTML="Hide";}else{jQuery("#greeting"+i).css('display','none');el(id).innerHTML="View all";}}},resetPopUpVariables:function(){id=(0<this.pokeTypeId)?this.pokeTypeId:1;el("poke"+id).className="";Comment.pokeTypeId=0;Comment.comment="";el('limitedtextarea').value="";if(el('so_name')){el('so_name').value="";el('so_email').value="";el('securityCode').value="";}},setPokeTypeId:function(_pokeTypeId){this.pokeTypeId=_pokeTypeId;},setCommentText:function(e){this.comment=this.tArea.value;},setPokeImage:function(pokeTypeId){switch(pokeTypeId){case 2:this.pokeImg='thumbsup.png';break;case 3:this.pokeImg='cheersmate.png';break;case 4:this.pokeImg='thaiwai.png';break;case 5:this.pokeImg='wave.png';break;case 6:this.pokeImg='bowdown.png';break;case 7:this.pokeImg='congratulate.png'
break;default:this.pokeImg='smile.png';}},setPokeType:function(pokeTypeId){switch(pokeTypeId){case 2:this.pokeType='thumbs up';break;case 3:this.pokeType='cheers mate';break;case 4:this.pokeType='thai wai';break;case 5:this.pokeType='wave';break;case 6:this.pokeType='bow down';break;case 7:this.pokeType='congratulate'
break;default:this.pokeType='smile';}},setDivId:function(divId){this.divId=divId;},setContextId:function(contextId){this.contextId=contextId;},setContext:function(context){this.context=context;},setPhotoCat:function(cat){this.photoCat=cat;},setImagePath:function(path){this.pokePath=path;},setAjaxPath:function(path){this.ajaxPath=path;},getPokeTypeId:function(){return this.pokeTypeId;},getDivId:function(){return this.divId;},getContext:function(){return this.context;},getAjaxPath:function(){return this.ajaxPath;},canAddGreeting:function(){return(((0<this.pokeTypeId&&0==this.comment.length)||(0<this.pokeTypeId&&0<this.comment.length)||(0==this.pokeTypeId&&0<this.comment.length))&&((((el('so_name'))&&""!=el('so_name').value)||!(el('so_name')))&&(((el('so_email'))&&""!=el('so_email').value)||!(el('so_email')))&&(((el('securityCode'))&&""!=el('securityCode').value)||!(el('securityCode')))))?true:false;},loadEffects:function(ob){var parent=ob.parentNode;ob.style.display='none';this.setOpacity(ob,0);},increaseOpacity:function(ob){var current=ob.style.opacity;if(this.lastob==ob&&this.lastop==current){current=current*10;var upone=current+1;this.setOpacity(ob,upone);this.lastob=ob;this.lastop=upone/10;}},decreaseOpacity:function(ob){var current=ob.style.opacity;if(this.lastob==ob&&this.lastop==current){current=current*10;var downone=current-1;this.setOpacity(ob,downone);this.lastob=ob;this.lastop=downone/10;}},setOpacity:function(ob,level){if(ob){var standard=level/10;var ie=level*10;ob.style.opacity=standard;ob.style.filter="alpha(opacity="+ie+")";}},mEffectAdd:function(ob){var temp=ob.style.backgroundColor;this.lastob=ob;this.lastop=1;ob.style.backgroundColor='#FEEBDF';ob.style.opacity=1;setTimeout(function(){for(var i=10;i>=5;i--)
setTimeout(function(){Comment.decreaseOpacity(ob);},i*50);},1500);setTimeout(function(){for(var v=1;v<=10;v++){setTimeout(function(){ob.style.backgroundColor=temp;Comment.increaseOpacity(ob);},v*250);}},2000);},mEffectShow:function(ob){ob.style.display='block';ob.style.visibility='visible';if(ob.style.opacity==0){this.lastob=ob;this.lastop=0;for(var i=1;i<=10;i++)
setTimeout(function(){Comment.increaseOpacity(ob);},i*50);setTimeout(function(){ob.style.filter='';},500);}},_center:function(elt){var pageWidth=(window.innerWidth!=null)?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null;var pageHeight=(window.innerHeight!=null)?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null;var posLeft=(typeof window.pageXOffset!='undefined')?window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft?document.body.scrollLeft:0;var posTop=(typeof window.pageYOffset!='undefined')?window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0;var height=jQuery(elt).height();var width=jQuery(elt).width();jQuery(elt).css({"position":"absolute","left":posLeft+((pageWidth-width)/2),"top":posTop+((pageHeight-height)/2)});},mEffectOut:function(ob){this.setOpacity(ob,0);ob.style.display='none';},showCommentBox:function(){if(0>=Comment.opac){var b='block',p='px',ht=120;var tp=this.posTop()+((this.pageHeight()-ht)/2)-112;Comment._center(jQuery('#mbox_comment'));Comment.resetPopUpVariables();Comment.setOpacity(el('mbox_comment'),5);Comment.setOpacity(el('comment_content'),1);st('mbox_comment').display=b;var _effects_=function(){Comment.opac=Comment.opac+5;Comment.setOpacity(el('comment_content'),Comment.opac);if(10>Comment.opac){_timer_=setTimeout(_effects_,0);Comment.setOpacity(el('mbox_comment'),10);}else{clearTimeout(_timer_);}};var _timer_=setTimeout(_effects_,0);}
return false;},hideCommentBox:function(){var _effects_=function(){Comment.opac=Comment.opac-5;Comment.setOpacity(el('comment_content'),Comment.opac);if(1<Comment.opac){_timer_=setTimeout(_effects_,0);}else{clearTimeout(_timer_);st('mbox_comment').display="none";}};var _timer_=setTimeout(_effects_,0);return false;},pageWidth:function(){return window.innerWidth!=null?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null;},pageHeight:function(){return window.innerHeight!=null?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null;},posLeft:function(){return typeof window.pageXOffset!='undefined'?window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft?document.body.scrollLeft:0;},posTop:function(){return typeof window.pageYOffset!='undefined'?window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0;},limitText:function(limitField,limitCount,limitNum){if(el(limitField).value.length>limitNum)
el(limitField).value=el(limitField).value.substring(0,limitNum);else
el(limitCount).value=limitNum-el(limitField).value.length;Comment.comment=el(limitField).value;},addComment:function(){if(this.canAddGreeting()){el('imgLoading1').style.display='';var name=(el('so_name'))?el('so_name').value:"";var email=(el('so_email'))?el('so_email').value:"";var securityCode=(el('securityCode'))?el('securityCode').value:"";query_string="action=savenew"+"&comment="+encodeURIComponent(this.comment)+"&context="+this.context+"&pokeType="+this.pokeTypeId+"&photoCat="+this.photoCat+"&contextID="+this.contextId+"&securityCode="+securityCode+"&name="+name+"&email="+email;(function($){$.ajax({url:"/comment.php",data:query_string,type:"POST",success:function(res){el('imgLoading1').style.display='none';var response=res.split("<<<>>>");switch(response[0]){case"1":window.location.href="/index.php";break;default:if(response[response.length-2]==4){st('mbox_comment').display='none';el('display_comments_content').style.display='none';el('greet_layer').style.display='none';el('imgLoading1').style.display='none';el(Comment.divId).innerHTML=response[response.length-1];Comment.opac=0;(typeof(window['Captcha'])!="undefined")?Captcha.load():"";if("2"==response[0]){cells=el(Comment.divId).getElementsByTagName('li');Comment.mEffectAdd(cells[0]);}}
else{(typeof(window['Captcha'])!="undefined")?Captcha.load():"";el('add_comment_alert').innerHTML=response[response.length-1];break;}}}});})(jQuery);}
else{var msg=(el('so_name')&&(""==el('so_name').value||""==el('so_email').value||""==el('securityCode').value))?"Please fill up the required fields(name, email, security code). ":"";msg=(!((0<this.pokeTypeId&&0==this.comment.length)||(0<this.pokeTypeId&&0<this.comment.length)||(0==this.pokeTypeId&&0<this.comment.length)))?'Please choose a greeting or add a comment!':msg;el('add_comment_alert').innerHTML=msg;}
Comment.tmpcommentid=0;},viewcomments:function(context,contextid,photocategory,genid,loginid){Comment.tmpcommentid=0;var timestamp=new Date();var params='action=view'+'&context='+context+'&contextID='+contextid+'&loginid='+loginid+'&timestamp='+(timestamp*1);var photocategory=photocategory?photocategory:false;if(photocategory){params=params+'&photocategory='+photocategory+'&genid='+genid;}
new Ajax.Updater('commentscontainer',Comment.getAjaxPath()+'comments.php',{method:'get',parameters:params,asynchronous:true,evalScripts:true,onLoading:function(){},onComplete:function(){jQuery("#commentscontainer").slideToggle("slow",function(){jQuery("#viewcomments").toggleClass('active');});}});},showedit:function(context,contextid,commentid,photocategory,genid,loginid){var timestamp=new Date();var params='action=showedit&context='+context+'&contextID='+contextid+'&commentid='+commentid+'&loginid='+loginid+'&timestamp='+(timestamp*1);params=(photocategory=='')?params:params+'&photocategory='+photocategory+'&genid='+genid;el('thecommenttext'+commentid).className='comment_text';st('commenteditloading'+commentid).display='block';new Ajax.Updater('thecommenttext'+commentid,Comment.getAjaxPath()+'comments.php',{method:'get',parameters:params,asynchronous:true,evalScripts:true,onComplete:function(){$('thecommenttext'+commentid).className='comment_text';$('actions'+commentid).style.display='none';if(Comment.tmpcommentid>0){Element.update('editcommentlayer_'+Comment.tmpcommentid,'');$('hidecomment_'+Comment.tmpcommentid).style.display='block';$('actions'+Comment.tmpcommentid).style.display='block';}
Comment.tmpcommentid=commentid;$('commenteditloading'+commentid).style.display='none';}});},saveedit:function(frmelem,commentid){(function($){el('editcommentloading').style.display='block';$.ajax({url:Comment.getAjaxPath()+'comments.php',data:Form.serialize(frmelem),type:"POST",success:function(res){jQuery("#"+Comment.divId).html(res);jQuery('#editcommentloading').attr("style","display = 'none'");jQuery("#thecommenttext"+commentid).attr("style","display = 'none'");}});})(jQuery);Comment.tmpcommentid=0;},deletecomments:function(context,contextid,commentid,photocategory,genid,loginid){var photocategory=photocategory!==''?photocategory:false;var params='action=delete&context='+context+'&contextID='+contextid+'&commentid='+commentid+'&loginid='+loginid;params=(photocategory)?params+'&photocategory='+photocategory+'&genid='+genid:params;Comment.commentID=commentid;var delete_comment=function(){(function($){el('commenteditloading'+Comment.commentID).style.display='block';$.ajax({url:Comment.getAjaxPath()+'comments.php',data:params,type:"GET",success:function(res){jQuery("#"+Comment.divId).html(res);CustomPopup.initPrompt("The comment has been successfully deleted.");CustomPopup.createPopup();}});})(jQuery);}
CustomPopup.initialize("Delete Comment ?","Do you want to delete this comment?",delete_comment,"Yes");CustomPopup.setJS(true);CustomPopup.createPopup();Comment.tmpcommentid=0;},canceledit:function(commentid,len){el('thecommenttext'+commentid).className=(0==len)?'':'comment_text';st('editcommentlayer_'+commentid).display='none';st('commenteditloading'+commentid).display='none';st('hidecomment_'+commentid).display='block';st('actions'+commentid).display='block';Comment.tmpcommentid=0;}};})(function(id){return document.getElementById(id);},function(id){return document.getElementById(id).style;});
