function toggle(div_id,arr_to_hide) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) 
	{	
		el.style.display = 'block';
		if(is_array(arr_to_hide))
		{	
			if(arr_to_hide)
			{
				
				for(var i=0; i<arr_to_hide.length; i++)
				{
					document.getElementById(arr_to_hide[i]).style.display="none";
				}
			}
		}
	}
	else 
	{
		el.style.display = 'none';
		if(is_array(arr_to_hide))
		{	
			if(arr_to_hide)
			{
				
				for(var i=0; i<arr_to_hide.length; i++)
				{
					document.getElementById(arr_to_hide[i]).style.display="inline";
				}
			}
		}
	}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.height;
	} else {
		viewportheight = document.documentElement.offsetHeight;
	}

	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
    {
       // alert(viewportheight);
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.offsetHeight;
		} else {
			blanket_height = document.body.offsetHeight;
		}
	}
	//alert(document.body.scrollHeight);
	//alert(blanket_height);
	blanket_height = document.body.scrollHeight;
	blanket_width = document.body.scrollWidth;
	
    viewportheight = getWindowDimension();
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	blanket.style.width = blanket_width + 'px';
	
	
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=viewportheight/2-150;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
	
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	
	viewportwidth = document.body.scrollWidth;
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-200;//450 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname,arr) {
	blanket_size(windowname);
	window_pos(windowname);
	if(arr)
	toggle('blanket',arr);
	else
	toggle('blanket');
	toggle(windowname);		
}
function is_array( mixed_var ) 
{
	var key = '';
 
    if (!mixed_var) {
        return false;
    }
 
    if (typeof mixed_var === 'object') {
 
        if (mixed_var.hasOwnProperty) {
            for (key in mixed_var) {
                // Checks whether the object has the specified property
                // if not, we figure it's not an object in the sense of a php-associative-array.
                if (false === mixed_var.hasOwnProperty(key)) {
                    return false;
                }
            }
        }     
 
        return true;
    }
 
    return false;
}
/* added by Anez.A */
function getWindowDimension (mode)
{
     var theWidth= theHeight=0;
    // Window dimensions:
    if (window.innerWidth) {
    theWidth=window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth) {
    theWidth=document.documentElement.clientWidth;
    }
    else if (document.body) {
    theWidth=document.body.clientWidth;
    }
    if (window.innerHeight) {
    theHeight=window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
    theHeight=document.documentElement.clientHeight;
    }
    else if (document.body) {
    theHeight=document.body.clientHeight;
    }
    if(mode)
    {
        if(mode==H)
            return theHeight;
        else
            return theWidth;
    }
    return theHeight;
}

