function savewindowstate(state, window){

        if(XMLHttpRequestObject) {
         var fulldatasource = "savewindowstate.php?state=" + state + "&wid=" + window;
          XMLHttpRequestObject.open("GET", fulldatasource); 

          XMLHttpRequestObject.onreadystatechange = function() 
          { 
            if (XMLHttpRequestObject.readyState == 4 && 
              XMLHttpRequestObject.status == 200) { 
	//alert("Saved Window State: " + state + " - " + window + fulldatasource);
	//alert(fulldatasource);
            } 
          } 

          XMLHttpRequestObject.send(null); 
        }

}

function closeWindow(divID, wid){

          var obj = document.getElementById(divID);
obj.style.visibility = 'hidden';
new Effect.Squish(obj);

savewindowstate('0', wid);
	obj.innerHTML = "";

}

function openWindow(divID, wid, type, path, height){

          var obj = document.getElementById(divID);
	var content = null;

obj.style.visibility = 'visible';

//if(type == '2'){
//content = "<td><p align='center'><iframe src='" + path + "' height=350 frameborder=0></iframe></td>";
//savewindowstate('1', wid);
//}

//if((type == '3') || (type == '4')){
content = "<iframe class='iframes' src='" + path +"' frameborder='0' height='" + height + "' style='width: 100%'></iframe>";
savewindowstate('1', wid);
//alert(content);
//}


obj.innerHTML = content;

new Effect.SlideDown(obj);

}

function editWidget(divID, wid, type, path, fontsize, desc, articles, height){

var obj = document.getElementById(divID);

obj.style.visibility = 'visible';
obj.style.background = '';

if(type == '4'){
var path = "edits/editxmltemplate.php?divname=" + divID + "&wid=" + wid + "&type=" + type + "&path=" + path + "&fontsize=" + fontsize + "&desc=" + desc + "&articles=" + articles + "&height=" + height;
var height = 125;
}else{
var path = "edits/editiframetemplate.php?divname=" + divID + "&wid=" + wid + "&type=" + type + "&path=" + path + "&fontsize=" + fontsize + "&desc=" + desc + "&articles=" + articles + "&height=" + height;
var height = 225;
}
content = "<iframe src='" + path + "' frameborder=0 width='100%' height='" + height + "' style='width: 100%'></iframe>";

obj.innerHTML = content;


}

function updateWidgetSize(divID, wid, size, type, path){

var obj = document.getElementById(divID);

        if(XMLHttpRequestObject) {
         var fulldatasource = "updatesize.php?size=" + size + "&wid=" + wid;
          XMLHttpRequestObject.open("GET", fulldatasource); 

          XMLHttpRequestObject.onreadystatechange = function() 
          { 
            if (XMLHttpRequestObject.readyState == 4 && 
              XMLHttpRequestObject.status == 200) { 
//	obj.innerHTML = XMLHttpRequestObject.responseText; 
            } 
          } 

          XMLHttpRequestObject.send(null); 
        }

parent.window.location = "../index.php";

//content = "<iframe src='../" + path + "' height='" + size + "' width='100%' frameborder=0></iframe>";
//alert(content + "  -  " + divID);
//obj.innerHTML = content;


}

function closeEffect(divID, wid){

var toremove = 'remove.php?wid=' + wid;

new Effect.Fade(document.getElementById(divID));

        if(XMLHttpRequestObject) {
          XMLHttpRequestObject.open("GET", toremove); 
          XMLHttpRequestObject.onreadystatechange = function() 
          { 
            if (XMLHttpRequestObject.readyState == 4 && 
              XMLHttpRequestObject.status == 200) { 
            } 
          } 

          XMLHttpRequestObject.send(null); 
        }

}
