
function setCookie(name,value,expires,path,domain,secure){var today=new Date();today.setTime(today.getTime());if(expires){expires=expires*1000*60*60*24;}
var expires_date=new Date(today.getTime()+(expires));document.cookie=name+"="+escape(value)+
((expires)?";expires="+expires_date.toGMTString():"")+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+
((secure)?";secure":"");}
function getCookie(c_name){if(document.cookie.length>0){c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1){c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}
return"";}
function add_watchlist(id){$("a.watchlist").click(function(){$.post("listing.action.php",{a:"addwatchlist",lid:id},function(data){if(data.added){$("#watchlist_"+id).html("Added in WatchList")}else if(data.notlogin){loginwindow();}},"json");});}
function loginwindow(message){$.get(CFG.urlpath+"/login/login.tpl.php",function(data){$("body").append(data);if(typeof(message)!="undefined"){$("#login_brief").text(message);}
$(".float_box").dialog({title:"Login to IOS",width:400,resizable:false,modal:true,close:function(event,ui){$(this).remove()}});$("#form_ajax_login").attr("action",CFG.wwwroot+"/login/login.php").submit(function(){$("#login_message").empty();$("<div>").html("Verify membership...").appendTo("#login_message");$.post(CFG.urlpath+"/login/login.php?mode=ajax",$(this).serialize(),function(data){$("#login_message").empty();if(data.loginsuccess==true){$("<div>").html("Login success. Please wait...").appendTo("#login_message");window.location.reload();}else{div=$("<div>").addClass("error").html("Combination of Email &amp; cannot be found.").appendTo("#login_message");div.delay(3000).fadeOut(2000);}},'json');return false;});$(".btnLogin").removeAttr("disabled");});}
function loading_small(ele){$(ele).html("<img src='"+CFG.urlpath+"/images/loading-38.gif'>");}
function signup_window(){$.get(CFG.urlpath+"/login/signup_dialog.tpl.php",function(data){$("body").append(data);$(".float_box").dialog({title:"Sign Up",width:400,resizable:false,modal:true,close:function(event,ui){$(this).remove()}});$("#form_ajax_signup").attr("action",CFG.wwwroot+"/login/signup.php").submit(function(){$("#signup_response").empty();$("<div>").html("Verifying...").appendTo("#signup_response");$.post(CFG.urlpath+"/login/signup.php?mode=ajax",$(this).serialize(),function(data){$("#signup_response").empty();if(data.success==true){$(".float_box").empty();$("<div>").html(data.response).appendTo(".float_box");}else{div=$("<div>").addClass("error").html(data.response).appendTo("#signup_response");div.delay(3000).fadeOut(2000);}},'json');return false;});});}
$(document).ready(function(){$("a.login").click(function(){loginwindow();return false;});$(".requirelogin").click(function(){if(userlogin==false){loginwindow("The feature require membership access.");}
return false;});$("a.signup").click(function(){signup_window();return false;});});function popiframe(url,text){var iframe=$("<iframe>").attr("src",url);var background=$("<div>").css("opacity",0.7).css("background-color","#000000").css("position","fixed").css("top",0).css("left",0).css("height",$(window).height()).css("width",$(window).width()).appendTo("body");var iframecontainer=$("<div>").attr("id","iframecontainer").appendTo("body");var text=$("<span>").html(text).css("padding",10).css("float","left").appendTo(iframecontainer);var button=$("<a>").attr("id","close").css("float","right").appendTo(iframecontainer);button.click(function(){$(this).parent().animate({top:$(window).height()},500,'linear',function(){$(this).remove();background.remove()});});$("<a>").html("[Take me to the page!]").css("padding",10).css("float","right").appendTo(iframecontainer).click(function(){window.open(url);});iframecontainer.css("position","fixed").css("z-index",1001).css("height",$(window).height()-50).css("width",$(document).width()-100).animate({top:'50px'},500,'linear').css("margin","auto").css("top",$(window).height()).css("left",$(window).width()/2-iframecontainer.width()/2);iframe.css("background","#ffffff").css("height","95%").css("width","100%").css("border","0").appendTo(iframecontainer);}
$(document).ready(function(){var listings;var firsttime=true;$("#q").val("Find your program...").click(function(){if(firsttime){$("#q").val("");firsttime=false;}});$.getJSON(CFG.urlpath+"/feed.php?a=getListings",function(data){listings=data;});$("#q").keyup(function(e){$("#q_result").empty();var typed_text;typed_text=$(this).val();typed_text=typed_text.trim();if(!listings){$("#q_result").hide();return false;}
if(typed_text==""){$("#q_result").hide();return false;}
$.each(listings,function(i,listing){var reg=new RegExp("^"+typed_text+"|\s"+typed_text+"","i");if(listing.name.match(reg)){var div_result=$("<div>").appendTo("#q_result");div_result.click(function(){window.location.href=listing.detail_url;});var l_name=listing.name.replace(new RegExp("("+typed_text+")","i"),"<span class='q_highlight'>$1</span>");$("<div>").addClass("listing_name").html(l_name).appendTo(div_result);$("<div>").addClass("listing_plan").html(listing.percents).appendTo(div_result);};});if(e.keyCode==13){$("#q_result").children().click();}
if(e.keyCode==9){}
if($("#q_result").html()==""){$("#q_result").hide();}else{$("#q_result").show();}
$("#q_result").css("top",$("#q").outerHeight()+$("#q").position().top).css("left",$("#q").position().left).css("width",$("#q").width()+4).css("height","inherit");});$("#BUTTONdropdown").toggle(function(){$("#q_result").empty();if(!listings){$("#q_result").hide();return false;}
$.each(listings,function(i,listing){var div_result=$("<div>").appendTo("#q_result");div_result.click(function(){window.location.href=listing.detail_url;});$("<div>").addClass("listing_name").html(listing.name).appendTo(div_result);$("<div>").addClass("listing_plan").html(listing.percents).appendTo(div_result);});if($("#q_result").html()==""){$("#q_result").hide();}else{$("#q_result").show();}
$("#q_result").css("top",$("#q").outerHeight()+$("#q").position().top).css("left",$("#q").position().left).css("width",$("#q").width()+4).css("height",200).css("overflow","auto");},function(){$("#q_result").hide();});$("body").click(function(evt){var target=evt.target;if(target.id!=='q_result'&&target.id!=='q'&&target.id!=="BUTTONdropdown"){$("#q_result").hide();}});});$(document).ready(function(){});String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim=function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim=function(){return this.replace(/\s+$/,"");}
var noticeObj=new Object();noticeObj.fadeAway=(function(words){if($("#noticeFade").length){$("#noticeFade").remove();}
$("<div id='noticeFade'/>").html(words).attr("style","position:absolute;background:white;border:2px solid black;padding:10px;background:#ffffdf").css("top",$(document).scrollTop()+150).appendTo("body").fadeOut(4000,function(){$(this).remove();});$("#noticeFade").css("left",$(document).width()/2-$("#noticeFade").width()/2);});noticeObj.lightbox=(function(message,title,backgroundCover,clickToVanish,fadeAwayTime){if(backgroundCover==undefined){backgroundCover=true;}
if(clickToVanish==undefined){clickToVanish=true;}
if(fadeAwayTime==undefined){fadeAwayTime=true;}
if(backgroundCover){var background=$("<div>");noticeObj.backgroundCover(background);}
var divNotice=$("<div>").appendTo("body");divNotice.addClass("lightbox_page");divNotice.css("top",$(document).scrollTop()+150);divNotice.css("z-index",1000);divNotice.css("left",$(document).width()/2-divNotice.width()/2);$("<div>").addClass("close_button").click(function(){divNotice.remove();background.fadeOut(500);}).appendTo(divNotice);if(title){$("<div>").addClass("title").html(title).appendTo(divNotice);}
$("<div>").css("padding",10).html(message).appendTo(divNotice);});noticeObj.backgroundCover=(function(background,opacity,bgcolor){if(opacity==undefined)opacity=0.5;if(bgcolor==undefined)bgcolor="#000000";background.css("position","absolute");background.css("left",0);background.css("top",0);background.css("opacity",opacity);background.css("background",bgcolor);background.css("width",$(document).width());background.css("height",$(document).height());background.hide().fadeIn(500);$(window).resize(function(){background.css("width",$(document).width());background.css("height",$(document).height());});background.unload(function(){$(window).unbind();});});$(document).ready(function(){if(typeof(google)=="undefined"){prepareTranslate();return;}
google.language.defaultLang="ENGLISH";google.language.defaultLangCode=google.language.Languages[google.language.defaultLang];google.language.defaultLang=getCookie("lang");google.language.defaultLangCode=google.language.Languages[google.language.defaultLang];if(!google.language.defaultLangCode){google.language.defaultLang="ENGLISH";google.language.defaultLangCode=google.language.Languages[google.language.defaultLang];}
prepareTranslate();$("#button_language-selection").html(google.language.defaultLang.toLowerCase().replace(/_/," ")).toggle(function(){$(this).addClass("openToggler");$("#container_language-selection").css("display","block");},function(){$(this).removeClass("openToggler");$("#container_language-selection").hide();});$.each(google.language.Languages,function(lang,i){var thisLangCode=google.language.Languages[lang];if(thisLangCode=="")return;var strLanguage=lang.toLowerCase().replace(/_/," ");var labelLang=$("<div>").html(strLanguage).click(function(){$("#button_language-selection").html(strLanguage).click();google.language.defaultLangCode=thisLangCode;$("#container_language-selection").hide();setCookie("lang",lang,1,"/");});$("#container_language-selection").append(labelLang);});$("body").click(function(evt){var target=evt.target;if(target.id!=='language-selection-container'&&target.id!=="button_language-selection"){$("#button_language-selection").click();$("#button_language-selection").click();}});});$(document).ready(function(){$(".input_monitor_status").attr("checked","checked");$(".input_monitor_status").click(function(){toggleListing();});});function toggleListing(){var div=$(".listing");if($(".input_monitor_status:not(:checked)").length){var hideClass="";var showClass="";$(".input_monitor_status:not(:checked)").each(function(){var value=$(this).val();hideClass+=".block_"+value+",";});$(".input_monitor_status:checked").each(function(){var value=$(this).val();showClass+=".block_"+value+",";});$(div).has(showClass.substring(0,showClass.length-1)).show();$(div).has(hideClass.substring(0,hideClass.length-1)).hide();}else{$(".listing").show();}}
function detectLanguage(text,callback){google.language.detect(text,function(result){if(!result.error){var langCode=result.language;callback(langCode);}});}
function translate(text,langCode,callback){google.language.translate(text,langCode,google.language.defaultLangCode,function(result){var translated=document.getElementById("translation");if(result.translation){callback(result.translation);}});}
function prepareTranslate(){if(typeof(google)=="undefined"){$(".buttonTranslate").hide();return;}
$(".buttonTranslate").toggle(function(){var button=$(this);var postcontent=$(this).parent().next(".postcontent");var text=postcontent.html();var div_translate=$(this).parent().parent().children(".postcontent_translate");button.append(" <img src=\""+CFG.urlpath+"/images/loading_mini.gif\">");detectLanguage(text,function(langcode){translate(text,langcode,function(translatetext){$(div_translate).html(translatetext);postcontent.hide();div_translate.show();button.text("Undo");});});},function(){var button=$(this);var postcontent=$(this).parent().next(".postcontent");var text=postcontent.html();var div_translate=$(this).parent().parent().children(".postcontent_translate");div_translate.hide();postcontent.show();$(this).text("Translate");});}
$(document).ready(function(){$("#vote_email").focus(function(){if($(this).val()=='Enter your E-mail'){$(this).val("");}});$("#vote_email").blur(function(){if($(this).val()==''){$(this).val("Enter your E-mail");}});$("#votenow").click(function(){$("ul.tab_h li:nth-child(2)").click();$("html, body").animate({scrollTop:$(".tab_bar").offset().top},1000);});});
