
var dc={};dc={$:function(id,doc){var doc=doc||document;return document.getElementById(id);},cookies:{set:function(name,value,expires){if(expires){var date=new Date();date.setTime(date.getTime()+expires);expires="; expires="+date.toGMTString();}else{expires="";}
document.cookie=name+"="+escape(value)+";expires="+expires;},get:function(name){if(document.cookie.length>0){cStart=document.cookie.indexOf(name+"=");if(cStart!=-1){cStart=cStart+name.length+1;cEnd=document.cookie.indexOf(";",cStart);if(cEnd==-1)cEnd=document.cookie.length;return unescape(document.cookie.substring(cStart,cEnd));}}
return"";},remove:function(name){this.parent.set(name,'',-1);}},getElementPos:function(el){var x=0;var y=0;if(el.getBoundingClientRect){var box=el.getBoundingClientRect();x=box.left+el.scrollLeft-el.clientLeft;y=box.top+el.scrollTop-el.clientTop;}else{x=el.offsetLeft;y=el.offsetTop;var parent=el.offsetParent;while(parent){x+=parent.offsetLeft;y+=parent.offsetTop;parent=parent.offsetParent;}}
return{'x':x,'y':y};},getBrowser:function(){var browser='';var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("msie")>-1){browser='IE';}else if(ua.indexOf("gecko")>-1){browser='GECKO';}else if(ua.indexOf("opera")>-1){browser='OPERA';}
return browser;},tabs:{id:{t:'',p:'',i:0,ts:'',ps:''},init:function(args){if(typeof(args.id)=="undefined"){return;}
if(typeof(args.sid)=="undefined"){args.sid=dc.cookies.get("tabs-pane-"+args.id);if(args.sid==""){args.sid=0;}}else{dc.cookies.set("tabs-pane-"+args.id,args.id,0);}
var ts=new Array,ps=new Array;var wrap=dc.$(args.id);var lis=wrap.getElementsByTagName("UL")[0].childNodes;var divs=wrap.getElementsByTagName("DIV");var j=0;for(var i=0;i<divs.length;i++){if(divs[i].className=="tabText"||divs[i].className=="tabText hide"){ps[j]=divs[i];j++;}}
j=0;for(var i=0;i<lis.length;i++){if(lis[i].nodeName=="LI"){lis[i].id=args.id+"T"+j;lis[i].tabsid=j;if(j==args.sid){lis[i].state=true;lis[i].className="selected";dc.tabs.id.t=lis[i];dc.tabs.id.p=ps[j];dc.tabs.id.i=j;if(ps[j].className=="tabText hide"){ps[j].className=ps[j].className.replace(" hide","");}}else{if(ps[j].className=="tabText"){ps[j].className+=" hide";}
lis[i].state=false;}
ts[j]=lis[i];j++;lis[i].onclick=function(){if(args.disabled==true){return;}
for(var i=0;i<ts.length;i++){if(ts[i].id==this.id){dc.cookies.set("tabs-pane-"+this.id.replace("T"+i,''),i,0);dc.tabs.setState.on(this,ps[i]);dc.tabs.id.t=ts[i];dc.tabs.id.p=ps[i];dc.tabs.id.i=i;}else{dc.tabs.setState.off(ts[i],ps[i]);}}}}}
dc.tabs.id.ts=ts;dc.tabs.id.ps=ps;if(dc.tabs.id.ps[args.sid].getAttribute('click')!=null){eval(dc.tabs.id.ps[args.sid].getAttribute('click'));}},setState:{on:function(t,p){if(!t.state){t.className='selected';p.className=p.className.replace(" hide","");t.state=true;if(p.getAttribute('click')!=null){eval(p.getAttribute('click'));}}},off:function(t,p){if(t.state){t.className="";p.className+=" hide";t.state=false;}}},next:function(){if(dc.tabs.id.t.id==dc.tabs.id.ts[dc.tabs.id.i+1].id){return;}else{dc.tabs.setState.on(dc.tabs.id.ts[dc.tabs.id.i+1],dc.tabs.id.ps[dc.tabs.id.i+1]);dc.tabs.setState.off(dc.tabs.id.t,dc.tabs.id.p);dc.tabs.id.t=dc.tabs.id.ts[dc.tabs.id.i+1];dc.tabs.id.p=dc.tabs.id.ps[dc.tabs.id.i+1];dc.tabs.id.i++;}},prev:function(){if(dc.tabs.id.t==dc.tabs.id.ts[0]){return;}else{dc.tabs.setState.on(dc.tabs.id.ts[dc.tabs.id.i-1],dc.tabs.id.ps[dc.tabs.id.i-1]);dc.tabs.setState.off(dc.tabs.id.t,dc.tabs.id.p);dc.tabs.id.t=dc.tabs.id.ts[dc.tabs.id.i-1];dc.tabs.id.p=dc.tabs.id.ps[dc.tabs.id.i-1];dc.tabs.id.i--;}},goTo:function(i){if(dc.tabs.id.i==i||i>=dc.tabs.id.ts.length){return;}else{dc.tabs.setState.on(dc.tabs.id.ts[i],dc.tabs.id.ps[i]);dc.tabs.setState.off(dc.tabs.id.t,dc.tabs.id.p);dc.tabs.id.t=dc.tabs.id.ts[i];dc.tabs.id.p=dc.tabs.id.ps[i];dc.tabs.id.i=i;}}}}
dc.ajax={handle:null,f:null,init:function(){try{this.handle=new XMLHttpRequest();}catch(e){try{this.handle=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{this.handle=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser does not support AJAX! We support: IE7, IE8, Firefox, Chrome, Opera, Safari.");this.handle=false;}}}},orsc:function(){switch(dc.ajax.handle.readyState){case 1:break;case 2:break;case 3:break;case 4:if(dc.ajax.handle.status==200){dc.ajax.f();}else{alert("Error! Please contact our master, thanks.");}
break;}},get:function(url,f){var b=dc.getBrowser();if(this.handle==null||b=='IE'){this.init();}
this.f=f;this.handle.onreadystatechange=this.orsc;this.handle.open('GET','/?module=ajax&action='+url+'&refresh='+Math.random(),true);this.handle.send(null);},post:function(url,f,p){if(this.handle==null){this.init();}
this.f=f;this.handle.onreadystatechange=this.orsc;this.handle.open('POST','/?module=ajax&action='+url,true);this.handle.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");this.handle.send(p);}}
dc.category=function(id,c){var pid=document.getElementById('p'+id);var cid=document.getElementById('c'+id);if(cid.getAttribute("state")==1){cid.className=cid.className.replace(' show','')+' hidden';cid.setAttribute("state",0);pid.className='plus';c.className=c.className.replace(' selected','');}else{if(cid.childNodes.length==0){dc.ajax.get('category&id='+id,function(){cid.innerHTML=dc.ajax.handle.responseText});}
cid.className=cid.className.replace(' hidden','')+' show';cid.setAttribute("state",1);pid.className='minus';c.className+=' selected';}};dc.win={handle:new Array(),bg:null,clientWidth:0,clientHeight:0,scrollTop:0,getSize:function(){this.clientWidth=document.body.clientWidth;this.clientHeight=document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;this.scrollTop=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;},creat:function(i,w,h){if(this.handle[i]==null){this.bg=document.createElement("div");this.bg.style.background="gray";this.bg.style.position='absolute';this.bg.style.filter="alpha(opacity=40)";this.bg.style.opacity="0.20";this.bg.style.top=0;this.bg.style.left=0;this.bg.style.zIndex='998';this.bg.style.display='none';this.handle[i]=document.createElement("div");this.handle[i].className='floatwin';this.handle[i].style.position='absolute';this.handle[i].style.zIndex='999';this.handle[i].style.display='none';this.resize(i,w,h);var sd=document.createElement("div");sd.className="right hand";sd.onclick=this.close;sd.title=i;var sdi=document.createElement("img");sdi.src="/public/images/close.gif";sdi.title='Close';sd.appendChild(sdi);this.handle[i].appendChild(sd);document.body.appendChild(this.bg);document.body.appendChild(this.handle[i]);}
return true;},resize:function(i,w,h){this.getSize();this.bg.style.width=this.clientWidth+'px';this.bg.style.height=this.clientHeight+'px';this.handle[i].style.width=w+'px';this.handle[i].style.height=h+'px';this.handle[i].style.left=((this.clientWidth-w)/2)+'px';this.handle[i].style.top=((this.clientHeight-h)/2+this.scrollTop)+'px';},close:function(t){if(dc.win.handle[this.title]==null){dc.win.handle[t].style.display="none";dc.win.bg.style.display="none";}else{dc.win.handle[this.title].style.display="none";dc.win.bg.style.display="none";}},show:function(i){if(this.handle[i]!=null){this.bg.style.display="";this.handle[i].style.display="";}}}
dc.login={handle:null,show:function(){if(dc.win.handle['login']==null){dc.win.creat('login',400,200);}else{dc.win.resize('login',400,200);}
if(dc.login.handle==null){dc.login.handle=document.createElement("div");dc.login.handle.id='login';dc.login.handle.innerHTML='Loading...';dc.ajax.get('login',function(){dc.login.handle.innerHTML=dc.ajax.handle.responseText;dc.win.handle['login'].appendChild(dc.login.handle)});}
dc.win.show('login');return false;},showValidate:function(e){var img=dc.$(e);if(img.src==''){img.src="/?module=login&action=validate";img.style.display='';}},changeValidate:function(e){var img=dc.$(e);if(img.src==''){img.src="/?module=login&action=validate";}else{img.src="/?module=login&action=validate&refresh="+Math.random();}},focus:function(e){var username=dc.$("username");var password=dc.$("password");var validate=dc.$("validate");validate.value='';if(username.value==""){username.focus();}else{password.focus();}
var img=dc.$(e);if(img.src!=''){this.changeValidate(e);}},check:function(){var username=dc.$("loginUsername");var password=dc.$("loginPassword");var validate=dc.$("loginValidate");if(username.value.length<2){alert("Please input your User Name.");username.focus();return false;}
if(password.value.length<6||password.value.length>16){alert("Please input your Password.");password.focus();return false;}
if(validate.value.length!=6){alert("Please input your Verification.");validate.focus();return false;}}}
dc.register={handle:null,show:function(){if(dc.win.handle['register']==null){dc.win.creat('register',400,270);}else{dc.win.resize('register',400,270);}
if(dc.register.handle==null){dc.register.handle=document.createElement("div");dc.register.handle.id='register';dc.register.handle.innerHTML='Loading...';dc.ajax.get('register',function(){dc.register.handle.innerHTML=dc.ajax.handle.responseText;dc.win.handle['register'].appendChild(dc.register.handle)});}
dc.win.show('register');return false;},check:function(){var reguUser="^([a-zA-Z0-9]+[_0-9a-zA-Z]{2,15})$";var reguEmail="^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2,3})$";var reUser=new RegExp(reguUser);var reEmail=new RegExp(reguEmail);var terms=dc.$("terms");var protocol=dc.$("regProtocol");if(protocol.checked==false){terms.style.border="2px solid red";alert("Please checked the Terms checkbox.");terms.style.border="0";return false;}
var username=dc.$("regUsername");if(username.value.length==0){alert("Please input your User Name");username.focus();return false;}
if(username.value.search(reUser)==-1){alert("Please input your User Name");username.focus();return false;}
var email=dc.$("regEmail");if(email.value.length==0){alert("Please input your Email.");email.focus();return false;}
if(email.length>100){alert("Please input your Email.");email.focus();return false;}
if(email.value.search(reEmail)==-1){alert("Please input your Email.");email.focus();return false;}
var password=dc.$("regPassword");var repassword=dc.$("regRepassword");if(password.value.length==0){alert("Please input your Password");password.focus();return false;}
if(password.value.length<6||password.value.length>16){alert("Please input your Password(at last 6 characters)");password.focus();return false;}
if(password.value==username.value){alert("The Password was not same to your User Name.");password.focus();return false;}
if(password.value!=repassword.value){alert("The password must same both.");repassword.focus();return false;}
var validate=dc.$("regValidate");if(validate.value.length==0){alert("Please input the Verification.");validate.focus();return false;}
if(validate.value.length!=6){alert("Please input the Verification.");validate.focus();return false;}}}
dc.comment={handle:null,replyHandle:null,t:'',i:0,r:0,form:function(t,i,a){this.t=t;this.i=i;if(dc.win.handle['comment']==null){dc.win.creat('comment',380,210);}else{dc.win.resize('comment',380,210);}
if(dc.comment.handle==null){dc.comment.handle=document.createElement("div");dc.comment.handle.id='commentForm';dc.comment.handle.innerHTML='Loading...';a=1;}
if(a==1){dc.ajax.get('comment&type='+t+'&id='+i,function(){dc.comment.handle.innerHTML=dc.ajax.handle.responseText;dc.win.handle['comment'].appendChild(dc.comment.handle)});}
dc.win.show('comment');},reply:function(t,i,p,a){this.t=t;this.i=i;if(dc.win.handle['commentReply']==null){dc.win.creat('commentReply',380,210);}else{dc.win.resize('commentReply',380,210);}
if(dc.comment.replyHandle==null){dc.comment.replyHandle=document.createElement("div");dc.comment.replyHandle.id='commentReplyForm';dc.comment.replyHandle.innerHTML='Loading...';a=1;}
if(a==1||this.r!=p){this.r=p;dc.ajax.get('commentReply&type='+t+'&id='+i+'&p='+p,function(){dc.comment.replyHandle.innerHTML=dc.ajax.handle.responseText;dc.win.handle['commentReply'].appendChild(dc.comment.replyHandle)});}
dc.win.show('commentReply');},check:function(){var cName=dc.$("commentName");if(cName.value.length<2){alert("Please input <Your Name>.");cName.focus();return false;}
var cText=dc.$("commentText");if(cText.value.length<4){alert("You need input <message>. (At last 2 words)");cText.focus();return false;}
return true;},post:function(){if(this.check()){dc.$("commentSubmit").disabled=true;dc.$("commentReset").disabled=true;var p=new Array();p.push('type='+this.t,'id='+this.i,'website='+dc.$("commentWebsite").value,'name='+escape(dc.$("commentName").value),'ctext='+escape(dc.$("commentText").value));dc.ajax.post('commentInsert',function(){dc.$("commentText").value='';dc.$("commentSubmit").disabled=false;dc.$("commentReset").disabled=false;dc.comment.handle.innerHTML=dc.ajax.handle.responseText;dc.comment.show(dc.comment.t,dc.comment.i)},p.join('&'));}
return false;},replyPost:function(){if(this.check()){dc.$("commentSubmit").disabled=true;dc.$("commentReset").disabled=true;var p=new Array();p.push('type='+this.t,'id='+this.i,'website='+dc.$("commentWebsite").value,'name='+escape(dc.$("commentName").value),'ctext='+escape(dc.$("commentText").value),'parentid='+dc.$('commentParentid').value);dc.ajax.post('commentInsert',function(){dc.$("commentText").value='';dc.$("commentSubmit").disabled=false;dc.$("commentReset").disabled=false;dc.comment.replyHandle.innerHTML=dc.ajax.handle.responseText;dc.comment.show(dc.comment.t,dc.comment.i)},p.join('&'));}
return false;},show:function(t,i){if(t!='icon'&&t!='software'){return;}
dc.ajax.get('commentList&type='+t+'&id='+i,function(){dc.$('commentList').innerHTML=dc.ajax.handle.responseText});},reset:function(){dc.$("commentName").value='';dc.$("commentWebsite").value='';dc.$("commentText").value='';}}
dc.forward={handle:null,t:'',i:0,form:function(t,i){this.t=t;this.i=i;if(dc.win.handle['forward']==null){dc.win.creat('forward',400,340);}else{dc.win.resize('forward',400,340);}
if(dc.forward.handle==null){dc.forward.handle=document.createElement("div");dc.forward.handle.id='forwardForm';dc.forward.handle.innerHTML='Loading...';}
dc.ajax.get('forward&type='+t+'&id='+i,function(){dc.forward.handle.innerHTML=dc.ajax.handle.responseText;dc.win.handle['forward'].appendChild(dc.forward.handle)});dc.win.show('forward');},check:function(){var fromEmail=dc.$('fromEmail');if(fromEmail.value.length<7){alert("Please input <Your E-Mail>.");fromEmail.focus();return false;}
var toEmail=dc.$('toEmail');if(toEmail.value.length<7){alert("Please input <Recipient email>.");toEmail.focus();return false;}
var subject=dc.$('subject');if(subject.value.length<4){alert("Please input <Subject>. (At last 2 words)");subject.focus();return false;}
var message=dc.$('message');if(message.value.length<2){alert("Please input <Message>. (At last 2 words)");message.focus();return false;}
return true;},post:function(){if(this.check()){dc.$("forwardSubmit").disabled=true;dc.$("forwardReset").disabled=true;var p=new Array();p.push('type='+this.t,'id='+this.i,'fromName='+escape(dc.$("fromName").value),'fromEmail='+escape(dc.$("fromEmail").value),'toName='+escape(dc.$("toName").value),'toEmail='+escape(dc.$("toEmail").value),'subject='+escape(dc.$("subject").value),'message='+escape(dc.$("message").value));dc.ajax.post('forwardInsert',function(){dc.$("forwardSubmit").disabled=false;dc.$("forwardReset").disabled=false;dc.$("toName").value='';dc.$("toEmail").value='';dc.forward.handle.innerHTML=dc.ajax.handle.responseText;},p.join('&'));}
return false;},reset:function(){dc.$("toName").value='';dc.$("toEmail").value='';dc.$("fromName").value='';dc.$("fromEmail").value='';dc.$("subject").value='';}}
dc.rating={s:function(id,a,t){if(t==2){t='software'}else if(t==3){t='comment';}else{t='icon';}
dc.ajax.get('rating&t='+t+'&id='+id+'&r='+a,function(){dc.$('rating'+id).innerHTML=dc.ajax.handle.responseText;dc.cookies.set(t+id,1,8640000);});}}
dc.favorite={s:function(id,t){if(t==2){t='software'}else{t='icon';}
dc.ajax.get('favorite&t='+t+'&id='+id,function(){dc.$('favorite').innerHTML=dc.ajax.handle.responseText;});}}