//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function openDimmerPopup(url, closeLabel)
{
	DrawIframeComponent.closeLabel	= closeLabel;
	
	ShowPopupDiv("overlay_image_print");
    DrawIframeComponent("divPopupContent", url, "full");

	return false;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''






/////////////////////////////////////popups
function DrawIframeComponent(id,url)
{
    var cont = document.getElementById(id);
    with([]){
        push('<div class="popup_outer">');
        push('<div class="popup_inner">');
        push('<div class="popup_bg">');
        push('<div class="popup_content">');
        push('<div class="icon_close"><a href="#" onclick="return ClosePopupDiv();"><img src="../../Images/dimmer/close2.gif" alt="Close" title="Close"/>'+DrawIframeComponent.closeLabel+'</a></div>');
        push('<iframe id="cIframe" src="../../TemplatesIframe/Loading/Loading.htm" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="490" height="460"></iframe>');
        push('</div>');
        push('</div>');
        push('</div>');
        push('</div>');
        cont.innerHTML = join(" ");
    }
    
    setTimeout(" document.getElementById('cIframe').src = '"+url+"';",1000);
}

/////////////////////////////////////base

function isnull(arg) {
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}
function getValuePart(obj, ind)
{
    try
    {   
        var val = obj.value.split(";")[ind];
        return val;
    }
    catch(e)
    {
        return "";
    }
}
function NameValueCollectionEntry(key, value)
{
	var _key = key;
	var _value = value;
    
	this.Key = _key;
	this.Value = _value;
}
function NameValueCollection()
{

	var _arr = new Array();		
    
	this.IsContainsKey = function(key)
	{
		return (GetIndexByKey(key) > -1);
	}
    
	this.Count = function()
	{
		return _arr.length;
	}											
    
    
	function GetIndexByKey(key)
	{
		for (var i=0; i<_arr.length; i++)
		{
			if (_arr[i].Key == key)
			{
				return i;
			}
		}					
		return -1;
	}
    

    
	this.Add = function(key, value)
	{
		var keyIndex = GetIndexByKey(key);
		var entry = new NameValueCollectionEntry(key, value);
		if (keyIndex == -1)
		{	
			_arr.push(entry);
		}
		else
		{
			_arr[keyIndex] = entry;
		}
	}
    
    
	this.GetByKey = function(key)
	{
		var keyIndex = GetIndexByKey(key);
		return (keyIndex != -1 ? _arr[keyIndex] : null);
	}
	
	this.GetByIndex = function(index)
	{
		return (index >= 0 && parseInt(index) < this.Count() ? _arr[index] : null);
	}
}

function ShowOverlayDiv()
{
    if (isIE6())
	{
		var divBodyOverLay = document.getElementById("divBodyOverLay");
		divBodyOverLay.style.position = "absolute";
		divBodyOverLay.style.width = "100%";
		divBodyOverLay.style.height = document.body.offsetHeight;
		divBodyOverLay.style.top = 0;
		divBodyOverLay.style.left = 0;
	}
	
	var divBodyOverLay = document.getElementById("divBodyOverLay");
    divBodyOverLay.className="overlay";
}
function CloseOverlayDiv()
{
	document.getElementById("divBodyOverLay").className="d_none";
}
function ShowPopupDiv(class_name){
    //document.getElementById("divPopupContent").innerHTML = "text text text";
    ShowOverlayDiv();
    
    boundedElements = null;
    
    var divPopupContent = document.getElementById("divPopupContent");
	if (divPopupContent)
	{
		divPopupContent.className=class_name;				
		
		divPopupContent.style.position = "fixed";
		divPopupContent.style.top = "50%";
		divPopupContent.style.left = "50%";
		divPopupContent.style.zindex = 99;
		
		var bounds = GetControlBounds(divPopupContent);				
		divPopupContent.style.marginTop = "-" + bounds.height / 2 + "px";
		divPopupContent.style.marginLeft = "-" + bounds.width / 2 + "px";
		
		if (isIE6())
		{
			divPopupContent.style.position = "absolute";
			divPopupContent.style.top = (document.documentElement.scrollTop + (bounds.height/2)) + ((window.screen.availHeight-bounds.height)/4) + "px";
			divPopupContent.style.left = "50%";
		}
	}
}

function isIE()
{
	return window.navigator.userAgent.toUpperCase().indexOf("MSIE") > 0;
}
function isIE6()
{
	return window.navigator.appVersion.toUpperCase().indexOf("MSIE 6") > 0;
}

function GetControlLocation(element) 
{
	var offsetX = 0;
	var offsetY = 0;
	var parent;
	for (parent = element; parent; parent = parent.offsetParent) {
		if (parent.offsetLeft) {
			offsetX += parent.offsetLeft;
		}
		if (parent.offsetTop) {
			offsetY += parent.offsetTop;
		}
	}
	return { x: offsetX, y: offsetY };
}
function GetControlBounds(element) {
	if (boundedElements == null)
	{
		boundedElements = new NameValueCollection();
	}
	if (!boundedElements.IsContainsKey(element))
	{
		var offset = GetControlLocation(element);
		var b = {};
		b.x = offset.x;
		b.y = offset.y;
		b.width = element.offsetWidth;
		b.height = element.offsetHeight;
		boundedElements.Add(element, b);		
	}
	return boundedElements.GetByKey(element).Value;
}
var boundedElements;
function ClosePopupDiv()
{
    CloseOverlayDiv();
	
	document.getElementById("divPopupContent").innerHTML = "";
	document.getElementById("divPopupContent").className="d_none";

	return false;	
}