/*
created by kumar
*/

function uploadWindow(object)
{
	// his fnction open up the main junction to the upload application of the system
	this.element = object;
	
	
	// function for getting left
	this.getLeft = function()
	{
	    var x = 0;
	    var elm;

	    p_elm = this.element;
    
	    if(typeof(p_elm) == "object"){
	      elm = p_elm;
	    } else {
	      elm = document.getElementById(p_elm);
	    }
	    while (elm != null) {
	      x+= elm.offsetLeft;
	      elm = elm.offsetParent;
	    }
	    return parseInt(x);
	
	}
	
	// function for getting left
	this.getWidth = function()
	{
	    var x = 0;
	    var elm;
	    
	    p_elm = this.element;
	    if(typeof(p_elm) == "object"){
	      elm = p_elm;
	    } else {
	     elm = document.getElementById(p_elm);
	    }
	    return parseInt(elm.offsetWidth);
	
	}
	
	// get the top co-ordinte of the component
	this.getTop = function() 
	{
		var y = 0;
		var elm;
	    	p_elm = this.element;

		if(typeof(p_elm) == "object"){
			elm = p_elm;
		} else {
			elm = document.getElementById(p_elm);
		}
		while (elm != null) {
			y+= elm.offsetTop;
			elm = elm.offsetParent;
		}
		return parseInt(y);
	}
	
	
	// get the top co-ordinte of the component
	this.getHeight = function() 
	{
		var y = 0;
		var elm;
	    	p_elm = this.element;

		if(typeof(p_elm) == "object"){
			elm = p_elm;
		} else {
			elm = document.getElementById(p_elm);
		}
		return parseInt(elm.offsetHeight);

	}
	// got the id
	this.window_id = this.element.id.replace("_id","");
	
	//alert(this.window_id);
	document.getElementById(this.window_id).style.display="block";
	document.getElementById(this.window_id).style.position = "absolute";
	document.getElementById(this.window_id).style.top = (this.getTop() + parseInt(this.getHeight()) + 3) + "px";
	document.getElementById(this.window_id).style.left = this.getLeft() + "px";
	document.getElementById(this.window_id).style.width = "350px";
	document.getElementById(this.window_id).style.height = "60px";
	document.getElementById(this.window_id).style.overflow = "hidden";
	document.getElementById(this.window_id).innerHTML = "<iframe frameborder='0' autoscroll='false' src='" + baselocation + "include/application/upload/upload.htm?" + this.window_id + "' width='348px' height='76px'></iframe>";
	
	
	
} // end of the function


function uploadClose(window_id)
{
	document.getElementById(window_id).style.display="none";
}


function uploadLoading(window_id)
{
	document.getElementById(window_id+"_id").innerHTML = "Uploading......";
	document.getElementById(window_id).style.display="none";
}

function uploadConfirm(window_id,namedata)
{
	$_data = window_id.replace("layer_file_","");
	
	document.getElementById($_data).value = namedata;
	document.getElementById(window_id+"_id").innerHTML = "Successfully uploaded";
	document.getElementById(window_id).style.display="none";
	
	try
	{
		$_data = window_id.replace("file_","link_");
		document.getElementById($_data).href = baselocation + "display/" + namedata;;
	}
	catch(e)
	{
	}
}

