/* Copyright: Copyright (c) 2008 http://ramui.com. All rights reserved.
This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script. */
var fwBusy=false;
var fwCount=0;
function fwSetBusy(){
fwBusy=true;
var id=window.setTimeout('fwBusy=false;',5000);}
function fwEditPage(id){
var url=fwBlogUrl()+"fw_blog/admin/index.php?qur=8M3M" + id + "M2";
window.open(url,'Edit','fullscreen=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,copyhistory=yes');}
function fw_trim(str){return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');}
function fw_connect(url,params){
if(fwBusy){return;}
var fw_connection;
try{fw_connection = new XMLHttpRequest();}
catch(e){
try{fw_connection = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){
try{fw_connection = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e){return false;}}}
fw_connection.open("POST", url, true);
fw_connection.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
fw_connection.setRequestHeader("Content-length", params.length);
fw_connection.setRequestHeader("fw_connection", "close");
fw_connection.send(params);
return(fw_connection);}
function fw_total_encode(str){
var s=escape(fw_trim(str));
s=s.replace(/\+/g,"%2B");
s=s.replace(/@/g,"%40");
s=s.replace(/\//g,"%2F");
s=s.replace(/\*/g,"%2A");
return(s);}
function fwAddComment(id){
var url=fwBlogUrl()+"fw_blog/extend.php?query=1M"+id;
var x=window.open(url,'Comment','width=520,height=500,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes');
if(!x){alert("Please allow popup to open.");}}
function fwBlogUrl(){
var thisscript = document.getElementsByTagName('script');
for (var i=0; i<thisscript.length; i++) {if(thisscript[i].src.indexOf('common.js')>=0){return(thisscript[i].src.replace('fw_blog/script/common.js',''));}}return '';}
function fwUpdate(){
fwCount++;
var url = fwBlogUrl()+"fw_blog/extend.php?query=5M"+fwStatID;
var params = "&count=" +fwCount;
var fw_connection=fw_connect(url,params);}
function fwLoadStat(){var x=window.setInterval("fwUpdate()",60000);}
function fwGetAddon(p,d){
var url=fwBlogUrl()+"fw_blog/extend.php?query=7M";
var params ="addon="+fw_total_encode(p);
var fw_connection=fw_connect(url,params);
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){
document.getElementById(d).innerHTML = fw_connection.responseText;}}}
function fwAddAjaxEvents(){
var ajax=document.getElementById("fw_ajaxmenu");
var div = ajax.getElementsByTagName('DIV');
for(var i in div){
if (div[i].className == "root"){
div[i].onmouseover = function(){this.className='root_hover';}
div[i].onmouseout = function(){this.className='root';}
div[i].onclick = fwAjaxClick;}}}
function fwAjaxClick(){
var parent=this.parentNode;
var folderName=(parent.id).substr(11);
if(parent.className=='hide'){
var url=fwBlogUrl()+"fw_blog/extend.php?query=6M";
var params = "folder=" + fw_total_encode(folderName);
var fw_connection=fw_connect(url,params);
if(fw_connection){parent.className='wait'}
fw_connection.onreadystatechange = function(){
if(fw_connection.readyState == 4 && fw_connection.status == 200){fwBusy=false;
parent.className='show';
parent.innerHTML="<div class=\"root\">"+folderName+"</div>"+fw_connection.responseText;fwAddAjaxEvents();}}}
else{
parent.className='hide';
parent.innerHTML="<div class=\"root\">"+folderName+"</div>";fwAddAjaxEvents();}}
