﻿// this code resodes in all the content pages enabling and resizes the containing frame to enable the footer to move up and down as the page size changes
window.onload = function()
{
    
    if (typeof(window.parent.UnFreezeScreen) != 'undefined') window.parent.UnFreezeScreen();
    //do resize these pages
    if (document.getElementById("frmSurvey")) return true;
    if (document.getElementById("frmFind")) return true;
    
    var objFrame = window.parent.document.getElementById('shopcontent');
    var minHeight = 600; //This specifies the minimum page height
    //var tree1 = window.parent.document.getElementById("treemenu1");
    if (navigator.userAgent.indexOf('Firefox')==-1)
    {
        if (objFrame) objFrame = objFrame.style;
    }

    if (objFrame )
    {
        if (document.body.clientHeight > minHeight)
        {
            objFrame.height = document.body.clientHeight;
        }
        else
        {
            objFrame.height = minHeight;
        }
    }
    focusControl ('objScroll');
    return true;
}

function focusControl(ctrlId) 
{
        var ctrl = document.getElementById(ctrlId);
        if (!ctrl) var ctrl =  window.parent.document.getElementById(ctrlId);
        if (!ctrl) return false;
        if (ctrl.Show) ctrl.Show();
        if (ctrl.DoFocus) ctrl.DoFocus();
        if (ctrl.SetFocus) ctrl.SetFocus();
        //if (ctrl.select) ctrl.select('text');
        if (ctrl.focus) ctrl.focus(); 
        if (ctrl.setFocus) ctrl.setFocus();
        if (ctrl.doFocus) ctrl.doFocus();
        return true;
 }
var timer = null;
var Status =  "";
var firstload= ""; 
timer = setInterval("check()", 250);
function check()
{
  if (document.getElementById("lblStatus") && document.getElementById("lblStatus").innerHTML)
  {
     if (firstload="")
     {
        Status = document.getElementById ("lblStatus").innerHTML;
        firstload="true";
     }
     if (document.getElementById("lblStatus") && document.getElementById("lblStatus").innerHTML)
     {
        if (document.getElementById ("lblStatus").innerHTML != Status )
        {
            var array = document.getElementById ("lblStatus").innerHTML.split("#");
            if (window.parent.UnFreezeScreen()) window.parent.UnFreezeScreen();
            if (array[2])
            {
               
               switch (array[2])
               {
                    case 'OK':
                        switch (array[3])
                        {
                            case "disablesurvey":
                                
                                window.top.disableSurvey();
                                break;
                            case "gohome":
                            alert (array[1]);
                            location.replace('home.aspx');
                            return true;
                            break;
                        }
                        break;
                    case 'COMMAND':
                        switch (array[3])
                        {
                            case "enablesurvey":
                                
                                var objFrame = window.parent.document.getElementById('survey');
                                if (objFrame && objFrame.height) 
                                {
                                   
                                    objFrame.height = (document.body.clientHeight -11);
                                    if (!isBrowser('MSIE'))
                                    {
                                        objFrame.width = '206px';
                                    }
                                }
                                if (array[4]) window.top.enableSurvey(array[4]);
                                return true;
                                break;
                              case "home":
                                location.replace('../home.aspx');
                                return true;
                                break;
                        }
                        break;
                }           
            }
            alert (array[1]);
            Status = document.getElementById ("lblStatus").innerHTML;
        }
    }
  } 
return;
}
function isBrowser(browserstring)
{
        var sBrowser = navigator.userAgent;
		if (sBrowser.search(browserstring) != -1)	
		{
		    return true;
		}
        return false;
}
function MakeAttribute(attName, attValue)
{
    var objAttribute=document.createAttribute(attName);
    objAttribute.value = attValue;
    return objAttribute;
}
