﻿var objData;
function pageWidgetDataHandler()
{
	// variables for request url,divid to be updated after response and divid for placing loading...
	this.xmlRequestUrl;
	this.ResponseUpdateDiv;
	this.LoadingDiv;
	this.destroyDivID;
	this.status=0;
	
	
	// functions for operations
	this.getUserFiles=GetFilesOfUser;	
	this.playLoading=playLoader;
	this.removeWidget=removePageWidget;
	this.getResponse= function(){ return objData };
}

function GetFilesOfUser()
{
 	var xmlHttpObj;
	var UpdationDiv = this.ResponseUpdateDiv;
	if (window.XMLHttpRequest)
	{
		xmlHttpObj = new XMLHttpRequest();
		xmlHttpObj.onreadystatechange = function(){	GetPublicFileOfUserResponseHandler(xmlHttpObj,UpdationDiv) } 
		xmlHttpObj.open("GET",this.xmlRequestUrl,true);
		xmlHttpObj.send(null);
	}
	else if (window.ActiveXObject)
	{
		xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP")
		if (xmlHttpObj)
		{
			xmlHttpObj.onreadystatechange = function(){	GetPublicFileOfUserResponseHandler(xmlHttpObj,UpdationDiv) }
			xmlHttpObj.open("GET",this.xmlRequestUrl,true);
			xmlHttpObj.send();
		}		
	}
}
function GetPublicFileOfUserResponseHandler(xmlObjectSent,ObjectDivID)
{
	if(xmlObjectSent.readyState == 4 && xmlObjectSent.status == 200)
	{
	    objData = xmlObjectSent.responseText;
	    document.getElementById(ObjectDivID).innerHTML=xmlObjectSent.responseText;
	    //to check the session exists
	    checkTheSession();
	}	
}
function playLoader()
{
	document.getElementById(this.LoadingDiv).innerHTML="Loading....";
}
function removePageWidget()
{
    var holderID=document.getElementById(this.destroyDivID);
//    alert(this.destroyDivID);
	holderID.innerHTML="";
	holderID.setAttribute("yuntaawidgetname","");
	holderID.setAttribute("name","");
	if(holderID.parentElement)
	{
		var parentHolder=holderID.parentElement;
	 	parentHolder.removeChild(holderID);
	}
	
}

// Scroll handler
function pageonScroll()
{
    var toolBarPosition= YAHOO.util.Dom.getXY("yuProfBox2");
    var currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
    var newPosition = (toolBarPosition[1]+currentOffset+" px");
    //alert(newPosition);
    YAHOO.util.Dom.setY(document.getElementById("yuProfBox2"),(toolBarPosition[1]+currentOffset+" px"));
    //document.getElementById("yuProfBox2").style.top=toolBarPosition[1]+currentOffset+" px";
}
