﻿function getHeight()
{
    var y;
    if (self.innerHeight) { y = self.innerHeight; }
    else if (document.documentElement && document.documentElement.clientHeight) {  
        y = document.documentElement.clientHeight;
    }
    else if (document.body) {
        y = document.body.clientHeight;
    }
    
    return y;
}

function getWidth()
{
    var x;
    if (self.innerHeight) { x = self.innerWidth; }
    else if (document.documentElement && document.documentElement.clientHeight) {  
        x = document.documentElement.clientWidth;
    }
    else if (document.body) {
        x = document.body.clientWidth;
    }
    
    return x;
}

function getElmHeight(elmID) {
    if(document.getElementById(elmID).clientHeight) {
        return document.getElementById(elmID).clientHeight;
    } 
    else { 
        if(document.getElementById(elmID).offsetHeight) {
            return document.getElementById(elmID).offsetHeight;
        }
    }
}

function getElmWidth(elmID) {
    if(document.getElementById(elmID).clientWidth) {
        return document.getElementById(elmID).clientWidth;
    } 
    else { 
        if(document.getElementById(elmID).offsetWidth) {
            return document.getElementById(elmID).offsetWidth;
        }
    }
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function openWindow(id, url, title, width, height, minimizable, maximizable, draggable, resizable)
{
	WindowUtilities.disableScreen("alphacube");
	
	var newwin 		= new Window(id, {className: "alphacube", title: title, width: width, height: height, resizable: resizable, draggable: draggable, maximizable: maximizable, minimizable: minimizable, url: (url+"&winid="+id), showEffect:Effect.Appear, hideEffect: Effect.Fade, effectOptions:{duration:0.3}}); 
	newwin.modal 	= true;			
	newwin.setZIndex(Windows.maxZIndex + 20);
	Windows.unsetOverflow(newwin);
	
	if (newwin.oldStyle)
	  win2.getContent().setStyle({overflow: newwin.oldStyle});
		
	newwin._checkIEOverlapping();
	
	newwin.showCenter();
}

function openModalWindow(id, url, title, width, height)
{
	openWindow(id, url, title, width, height, false, false, false, false);
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

