﻿function common_showHelpDiv(objIcon)
{

    objIcon.src = objIcon.src.replace("Off", "Hover");
        
    var objDiv = document.getElementById(objIcon.id.replace("imgIcon", "div"));
    objDiv.style.display = "";
    
    //add iframe to cover dropdownlist
    var objIframe = document.getElementById(objIcon.id.replace("imgIcon", "iframe"));
   
    if (objIframe != null)
    {
        objIframe.style.top = objDiv.style.top;
        objIframe.style.left = objDiv.style.left;
        objIframe.style.width = objDiv.offsetWidth;
        objIframe.style.height = objDiv.offsetHeight;
        objIframe.style.marginTop = "21px";
        objIframe.style.marginLeft = "-11px";
        objIframe.style.zIndex = "999";
        objIframe.style.display = "";
        objDiv.style.zIndex = "1000";
     }
    
}

function common_hideHelpDiv(objIcon)
{
    objIcon.src = objIcon.src.replace("Hover", "Off");
    
    var objDiv = document.getElementById(objIcon.id.replace("imgIcon", "div"));
    objDiv.style.display = "none";
    
    var objIframe = document.getElementById(objIcon.id.replace("imgIcon", "iframe"));
    if (objIframe != null)
    {
        objIframe.style.display="none";
    }
}


function trim(s)
{
	return s.replace(/^\s+|\s+$/g,"");
}

function confirmDelete(msg)
{
  if (confirm(msg)==true)
    return true;
  else
    return false;
}

function common_getLeft(nObjWidth)
{
    var scrollx = (document.all)?document.documentElement.scrollLeft:window.pageXOffset; 
   
    var frameWidth;
    
    if (self.innerWidth)
    {
	    frameWidth = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
	    frameWidth = document.documentElement.clientWidth;
    }
    else if (document.body)
    {
	    frameWidth = document.body.clientWidth;
    }
    
    return ((frameWidth - nObjWidth) / 2 + scrollx)+ "px";
    
}

function common_getTop(nObjHeight)
{
    var scrolly  = (document.all)?document.documentElement.scrollTop:window.pageYOffset; 
   
    var frameHeight;
    
    if (self.innerWidth)
    {
	    frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
	    frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
	    frameHeight = document.body.clientHeight;
    }
    
    return ((frameHeight - nObjHeight) / 2 + scrolly)+ "px";
    
}

function open_HELP(URLHELP)
{
     mywin =window.open(URLHELP,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=795,height=657');
}
function common_openPopupWinChat(strUrl)
{
    var features = common_getPopupFeatures();
    win = window.open(strUrl, "win", features);
    win.focus();
    //javascript:common_openPopupWinChat('/medifast/Members/Community/Chat/client/chatwindow.asp');
}
function common_getPopupFeatures()
{
    // width
    var  nWidth = 680;

    // height
    var  nHeight = 517;

    // left
    var nLeft = ((screen.width - nWidth) / 2);

    // top
    var nTop = ((screen.height - nHeight) / 2);

    // scroll
    var hasScroll = "0";

    // resizable
    var isResizable = 1;

    // toolbar
    var hasToolbar = 0;

    // status
    var hasStatus = 0;

    var features = "height=" + nHeight + "px,\
			        width=" + nWidth + "px,\
			        left=" + nLeft + "px,\
			        top=" + nTop + "px,\
			        scrollbars=" + hasScroll + ",\
			        resizable=" + isResizable + ",\
			        toolbar=" + hasToolbar + ",\
			        status=" + hasStatus;

	return features;
}
