



	/**
	 * wnb tool tip
	 * @param loadingdiv
	 * @param mode
	 * @param message
	 * @return
	 */
	function ttp(loadingdiv,mode,message){	
		switch(mode){
		case "on":
			document.getElementById(loadingdiv).style.display = 'block';
			$(loadingdiv).className = 'activetip'
			document.getElementById(loadingdiv).innerHTML = message;
			return true;
		break;
		case "off":
			$(loadingdiv).className = ''
			document.getElementById(loadingdiv).style.display = 'none';
			return true;
		break;
		}
	}


	/**
	 * loader for games and software
	 * @param did
	 * @return
	 */
	function csl(did){
		if(document.getElementById(did).style.display == 'none'){
			new Effect.SlideDown(did,{ duration: 1.0,queue: 'end' });
		}else{
			new Effect.SlideUp(did,{ duration: 1.0,queue: 'end' });
		}
	}
	
	/**
	 * publisher page
	 * @param this_div
	 * @return
	 */
	function openallin(this_div){
		document.getElementById(this_div).innerHTML = "";
	}
	
    /**
     * 
     * @param this_div
     * @param cat_id
     * @param file_list
     * @return
     */
    function getlist(this_div,cat_id,file_list){
    	
    	new Ajax.Request(ddopath+file_list+'.php?this_cat='+cat_id+"&this_div="+this_div,{
    		onLoading:function(){
    			document.getElementById(this_div).innerHTML = "<img src=\""+extpath+"images/icons/loader.gif\" border=\"0\" />";
    		},onSuccess:function(transport){
    			response=transport.responseText;
    			document.getElementById(this_div).innerHTML = response;
    			new Effect.ScrollTo(this_div);
    		}
    	});	
    }

	/**
	 * generate tweet url and send to your status
	 * @param ptitle is product title
	 * @return mixed
	 */
	function tweet(ptitle){
		 BitlyCB.shortenResponse = function(data) {
			 var first_result;
			 for(var r in data.results) {
				 first_result = data.results[r]; break;
			 }
			 for(var key in first_result) {
				 if(key=="shortUrl"){
					 window.location = 'http://twitter.com/home/?status='+encodeURIComponent(ptitle)+' '+first_result[key].toString(); break;
				 }
			 }
		 }
		 BitlyClient.shorten(document.location, 'BitlyCB.shortenResponse');
	}
	
	/**
	 * RBO
	 * @param s
	 * @return
	 */
	function UnCryptMailto(s){
        var n=0; var r="";
        for(var i=0; i<s.length; i++){
            n = s.charCodeAt(i);
            if(n>=8364){
            	n=128;
            }
            r += String.fromCharCode(n-1);
        }
        return r;
    }

	/**
	 * RBO
	 * @param s
	 * @return
	 */
    function linkTo_UnCryptMailto(s){
    	location.href=UnCryptMailto(s);
    }
	
    /**
     * 
     * @param this_div
     * @param this_uri
     * @param this_form
     * @return
     */
    function axupdater(this_div,this_uri,this_form){
    	var serialize=Form.serialize($(this_form));
    	new Ajax.Request(ddopath+this_uri+'.php?'+serialize,{
    		onLoading:function(){
    			document.getElementById(this_div).innerHTML = "<img src=\""+extpath+"images/icons/loader.gif\" border=\"0\" />";
    		},onSuccess:function(transport){
    			response=transport.responseText;
    			parsedstring = response.split("@@");
    			document.getElementById(this_div).innerHTML = parsedstring[1];
    			if(parsedstring[0]=='false'){
    				
    			}else{
    				csl(this_form);
    				window.setTimeout("csl('software-suggestion')",2000);
    			}
    		}
    	});
    }

    /**
     * set package and try to open
     * @return
     */
    function speedtest(size){
    	// XML http REQ
        if (window.XMLHttpRequest){
        	http=new XMLHttpRequest();
        }else if (window.ActiveXObject){
            http=new ActiveXObject("Microsoft.XMLHTTP")
        }
    	
    	document.getElementById('dltreturn').innerHTML = "<img src=\""+extpath+"images/icons/loader.gif\" border=\"0\" />";
    	if(http){
			url=extpath+'cache/package.tar.gz?'+new Date().getTime();
			http.open('GET',url,false);
			var now=new Date();
			starttime=now.getTime();
			http.send(null);
			xsize=calctimte(handlehttpreply(),size);
			document.getElementById('dltreturn').innerHTML = xsize;
    	}else{
    		document.getElementById('dltreturn').innerHTML = 'error while speed test';
    	}
    	
        /**
         * http handler for ax
         * @return
         */
        function handlehttpreply(){
        	if((http.readyState==4) && (http.status==200)){
        		var now=new Date();
    			var time=(now.getTime()-starttime)/1000;
    			var filesize=http.getResponseHeader("Content-Length")/1024;
    			var speed=filesize/time;
    			return speed.toFixed(1);
        	}
        }
    }
    
    function calctimte(speed,size){
    	kb=size*1024; se=kb/speed; re=(se/60)+1;
    	return Math.round(re);
    }

    
    document.observe('dom:loaded',function(){
    	$('suggest-search-form').focusFirstElement();
    });
    
    