//----------------------------------------- 
// The Omniture functions have been moved to the s_code.aspx file.
// The below provides dummy stubs if the Omniture code does not
// get included on the page.
//
// since the s_code.aspx page gets included after this global.js
// the functions in the s_code.aspx will overwrite these stub functions
//
// these overrides were inside a function called in an onload event
// this causes timing issues with other code. these calls need to be inline.
DoOmnitureCustomLink = new Function();
DoOmnitureWebSearchKeywordCustomLink = new Function();

//---------------------------------------------------------
var browserIE=(navigator.appName=='Microsoft Internet Explorer')?true:false;
var browserOpera=(navigator.appName=='Opera')?true:false;
var browserChrome=(navigator.appName=='Netscape'&&navigator.appVersion.indexOf('Chrome')>-1)?true:false;
var browserSafari=(navigator.appName=='Netscape'&&!browserChrome&&navigator.appVersion.indexOf('Safari')>-1)?true:false;
var browserFirefox=(navigator.appName=='Netscape'&&!browserSafari&&!browserChrome)?true:false;
var browserOther=(!browserIE&&!browserOpera&&!browserChrome&&!browserSafari&&!browserFirefox)?true:false;

//---------------------------------------------------------
function left(str, n)
{
    if (n <= 0) return "";
    else if (n > String(str).length)  return str;
    else return String(str).substring(0,n);
}

//---------------------------------------------------------
function GoToPage(url)
{
	window.location=url;
}

//---------------------------------------------------------
function BackLink()
{
	window.history.back();
}

//---------------------------------------------------------
// trims strings of white space front and rear
function trim(s)
{
	s = s.replace(/^\s*/g,"").replace(/\s*$/g,"");
	return s;
}

//---------------------------------------------------------
// returns true if input string contains html, otherwise false
function ContainsHTML(input)
{
  var re = new RegExp(/<[a-zA-Z\/][^>]*>/);
  if (input.match(re) != null)
   return true;
  else
   return false;
 }


//---------------------------------------------------------
// limits the textarea pThis to nStrLen characters
function TextAreaLimitor(pThis, nStrLen)
{          
  var nLen = pThis.value.length;
  if(nLen > nStrLen)
  {	           	    
    // Set value equal to nStrLen characters.
    pThis.value = pThis.value.substring(0,nStrLen);
    return false;
  }        	  
  return true;        	  	  
}
//---------------------------------------------------------
function TextAreaLimitor_UpdateRemainingChars(pThis, pId, nStrLen) {
    var obj = document.getElementById(pId);

    var nLen = pThis.value.length;
    obj.innerHTML = nStrLen - nLen;
}

function MakeValidFileName(str)
{
	return str.replace(/\?|\:|\&|\/|\\|\*|\>|\<|\||\"/g, "-");
}

//-----------------------------------------
function openFriendlyName(objAnchor)
{
	var url = objAnchor.getAttribute('FriendlyURL').replace(/ /g, '%20') + objAnchor.getAttribute('FriendlyName').replace(/ /g, '%20');
  window.open(url);

	return false;
}

//-----------------------------------------
function printPage()
{
    try{window.print();}
    catch(e){}
}

//--------------------------------------------------------------
function urlEscape(sVal) {
	var sRet = sVal;
	var re;

    //ENCODE THE % FIRST!!!!
    re = /\%/gi; //(percentage)
	sRet = sRet.replace(re, "%25");
	
     re = /\:/gi; //(colon)
	sRet = sRet.replace(re, "%3A");
     re = /\;/gi; //(semi-colon)
	sRet = sRet.replace(re, "%3B");
     re = /\//gi; //(forward slash)
	sRet = sRet.replace(re, "%2F");
     re = /\\/gi; //(backslash)
	sRet = sRet.replace(re, "%5C");
     re = /\!/gi; //(exclamation)
	sRet = sRet.replace(re, "%21");
     re = /\"/gi; //(inverted comma)
	sRet = sRet.replace(re, "%22");
     re = /\#/gi; //(hash)
	sRet = sRet.replace(re, "%23");
     re = /\?/gi; //(question mark)
	sRet = sRet.replace(re, "%3F");
     re = /\=/gi; //(equals)
	sRet = sRet.replace(re, "%3D");
     re = /\@/; //(at)
	sRet = sRet.replace(re, "%40");
     re = /\>/gi; //(greater than)
	sRet = sRet.replace(re, "%3E");
     re = /\</gi; //(less than)
	sRet = sRet.replace(re, "%3C");
     re = /\$/gi; //(dollar)
	sRet = sRet.replace(re, "%24");
     re = /\&/gi; //(ampersand)
	sRet = sRet.replace(re, "%26");
     re = /\[/gi;
	sRet = sRet.replace(re, "%5B");
     re = /\]/gi; 
	sRet = sRet.replace(re, "%5D");
     re = /\~/gi; //(tilde)
	sRet = sRet.replace(re, "%7E");
     re = /\^/gi;
	sRet = sRet.replace(re, "%5E");
     re = /\`/gi; 
	sRet = sRet.replace(re, "%60");
     re = /\{/gi; //(opening bracket)
	sRet = sRet.replace(re, "%7B");
     re = /\}/gi; //(closing bracket)
	sRet = sRet.replace(re, "%7D");
    re = /\|/gi; //(pipe)
	sRet = sRet.replace(re, "%7C");
	
	return(sRet);
}

function isValidEmailAddress(value) {
    var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    return regex.test(value);
}

//-----------------------------------------
function emailPage(subject, body)
{
    if(subject==null)
    {
        var title=document.getElementsByTagName("title")[0];

        if(title!=null)
            subject=title.text;
    }

    if(body==null || body=="")
    {
        body=window.location.href;
    }

	try
	{
		var oApp = new ActiveXObject("Outlook.Application");
		var oItem = oApp.CreateItem(0); // New email message
		oItem.Subject=subject;
		oItem.Body=body;
		oItem.Display();
	}
	catch(e)
	{
	    var win=window.open("mailto:?subject=" + urlEscape(subject) + "&body=" + urlEscape(body));
		try{win.close();}catch(e){}
	}
}

//-----------------------------------------
function openEmail(objAnchor)
{
	var attachment = objAnchor.getAttribute('attachment').replace(/ /g, '%20');
	var subject = objAnchor.getAttribute('email_subject');
	var body = objAnchor.getAttribute('email_body');
	try
	{
		var oApp = new ActiveXObject("Outlook.Application");
		var oItem = oApp.CreateItem(0); // New email message
		oItem.Subject=subject;
		oItem.Body=body;
		oItem.Attachments.Add(attachment);
		oItem.Display();
	}
	catch(e)
	{
	    var win=window.open("mailto:?subject=" + urlEscape(subject) + "&body=" + urlEscape(body));
			try{win.close();}catch(e){}
	}
	return false;
}

//-----------------------------------------
function liveIt() {
    var title = document.title;
    title = title.replace(/\?|\:|\&|\/|\\|\*|\>|\<|\||\"/g, "");
    
    var url = 'https://favorites.live.com/quickadd.aspx?marklet=0&mkt=' + LanguageCode + '-' + CountryCode + '&title=' + title + '&url=' + escape(window.location.href);

    window.open(url, 'LiveIt', "height=250,width=300,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

//-----------------------------------------
function ctag(url, psid)
{
	if(trim(url)!=''&&trim(psid)!='')
	{
		var img=new Image;
		img.src=url+'&PS='+psid;
	}	
}

//-----------------------------------------
// Will call LoadFunction once the entire page is loaded
// - LoadFunction - string - function to be called when the page is loaded
//-----------------------------------------
function CrossBrowser_AttachLoadEvent(LoadFunction)
{
	try
	{
	    $(document).ready(function() {LoadFunction();}); //jquery document ready function

//	    if (window.addEventListener)
//		{
//			window.addEventListener('load', LoadFunction , false);
//			//eval("window.addEventListener('load', " + LoadFunction + ", false)");
//		}
//		else
//		{
//			window.attachEvent('onload', LoadFunction);
//			//eval("window.attachEvent('onload', " + LoadFunction + ")");
//		}
	}
	catch(e){;}	
}

//-----------------------------------------
// The array to hold all XMLHTTP Requests
// Exclusively used by CrossBrowser_GetAsyncRequest function
//-----------------------------------------
var CrossBrowser_XMLRequests = new Array();

//-----------------------------------------
// Custom XML Request object to hold other data
// Exclusively used by CrossBrowser_GetAsyncRequest function
// - XMLRequest - object = the xmlhttp request object
// - SuccessFunction - string = the function to call when the request is complete
// - SuccessFunctionParam - object = the parameter to pass to the SuccessFunction (can be null or an array)
//-----------------------------------------
function CrossBrowser_XMLRequest(XMLRequest, SuccessFunction, SuccessFunctionParam, ContainerID, FailedFunction, FailedFunctionParam)
{
	this.XMLRequest = XMLRequest;
	this.SuccessFunction = SuccessFunction;
	this.SuccessFunctionParam = SuccessFunctionParam;
	this.SuccessFunctionCalled = false;
	this.FailedFunction = FailedFunction;
	this.FailedFunctionParam = FailedFunctionParam;
	this.FailedFunctionCalled = false;
	this.ContainerID = ContainerID;
}

//-----------------------------------------
// Send a cross browser, asynchronous, xmlhttp call.
// URL - string = the url of the xml to fetch
// SuccessFunction - string = the funciton to call when the xml data is ready
// SuccessFunctionParam - object = the paramater to pass to the SuccessFunction - optional
// LoadingImage_ContainerID - id of container to show loading image
// LoadingImage_Size - size of loading image to display
//-----------------------------------------
function CrossBrowser_GetAsyncRequest(URL, ContainerID, LoadingImage_Size, SuccessFunction, SuccessFunctionParam, FailedFunction, FailedFunctionParam) 
{
	try {
	    var Container = document.getElementById(ContainerID);
	    if (Container != null && LoadingImage_Size != null) {
	        switch(LoadingImage_Size.toString().toUpperCase())
	        {
	            case "XLARGE":
	                Container.innerHTML = "<div style='align:center' align='center'><img src='../img/loading_256x256.gif' alt='' width='256px' height='256px'/></div>";
	                break;
	            case "LARGE":
	                Container.innerHTML = "<div style='align:center' align='center'><img src='../img/loading_128x128.gif' alt='' width='128px' height='128px'/></div>";
	                break;
	            case "MEDIUM":
	                Container.innerHTML = "<div style='align:center' align='center'><img src='../img/loading_64x64.gif' alt='' width='64px' height='64px'/></div>";
	                break;
	            case "XSMALL":
	                Container.innerHTML = "<div style='align:center' align='center'><img src='../img/loading_16x16.gif' alt='' width='16px' height='16px'/></div>";
	                break;
	            case "SMALL":
	            default:
	                Container.innerHTML = "<div style='align:center' align='center'><img src='../img/loading_32x32.gif' alt='' width='32px' height='32px'/></div>";
	                break;
	        }
	    }
		var XMLRequest = false;
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest)
		{
			XMLRequest = new XMLHttpRequest();
			XMLRequest.onreadystatechange = CrossBrowser_XMLRequestReady;
			XMLRequest.open("GET", trim(URL), true);
			XMLRequest.send(null);  
		}
		// branch for IE/Windows ActiveX version
		else if (window.ActiveXObject)
		{
			XMLRequest = new ActiveXObject("Microsoft.XMLHTTP");
			if (XMLRequest) {
				XMLRequest.onreadystatechange = CrossBrowser_XMLRequestReady;
				XMLRequest.open("GET", trim(URL), true);
				XMLRequest.send();
			}
		}
		if (XMLRequest)
		{
		    var oCrossBrowser_XMLRequest = new CrossBrowser_XMLRequest(XMLRequest, SuccessFunction, SuccessFunctionParam, ContainerID, FailedFunction, FailedFunctionParam);
			CrossBrowser_XMLRequests.push(oCrossBrowser_XMLRequest);
		}
	}
	catch(e)
	{ ; }	
}

//-----------------------------------------
// Called when an XMLHTTP request has had a state change
// Exclusively used by CrossBrowser_GetAsyncRequest function
// When ready, calls the SuccessFunction with the SuccessFunctionParam
//-----------------------------------------
function CrossBrowser_XMLRequestReady() 
{
	try
	{
		for (var i = 0; i < CrossBrowser_XMLRequests.length; i++)
		{	
			if (CrossBrowser_XMLRequests[i].XMLRequest.readyState == 4) // ready
			{
			    if (CrossBrowser_XMLRequests[i].XMLRequest.status == 200) // no error
			    {
			        if (!CrossBrowser_XMLRequests[i].SuccessFunctionCalled) {
			            CrossBrowser_XMLRequests[i].SuccessFunctionCalled = true;
			            eval(CrossBrowser_XMLRequests[i].SuccessFunction + "(CrossBrowser_XMLRequests[i].XMLRequest, CrossBrowser_XMLRequests[i].SuccessFunctionParam)");
			        }
			    }
			    else // error
			    {
			        if (!CrossBrowser_XMLRequests[i].FailedFunctionCalled) {
			            CrossBrowser_XMLRequests[i].FailedFunctionCalled = true;

			            var Container = document.getElementById(CrossBrowser_XMLRequests[i].ContainerID);
			            if (Container != null) {
			                Container.innerHTML = AJAX_ERRORMESSAGE;
			            }
			            else {
			                alert(AJAX_ERRORMESSAGE);
			            }

			            if (CrossBrowser_XMLRequests[i].FailedFunction != null)
			                eval(CrossBrowser_XMLRequests[i].FailedFunction + "(CrossBrowser_XMLRequests[i].XMLRequest, CrossBrowser_XMLRequests[i].FailedFunctionParam)");

			        }
			    }
			}
        }
	}
	catch(e)
	{ ; }	
}

//-----------------------------------------
function CrossBrowser_GetXML(URL, PostXML) 
{
	var xmlhttp=CrossBrowser_GetXMLHTTPRequest(trim(URL), PostXML);
	if(xmlhttp)
		return xmlhttp.responseXML;
	else
		return null;
}
//-----------------------------------------
function CrossBrowser_GetHTML(URL, PostXML) 
{
	var xmlhttp=CrossBrowser_GetXMLHTTPRequest(trim(URL), PostXML);

	if(xmlhttp)
		return xmlhttp.responseText;
	else
		return null;
}
//-----------------------------------------
function CrossBrowser_GetXMLHTTPRequest(URL, PostXML) 
{
	try
	{
		var XMLRequest = false;
		var PostGet="Get";

		if (PostXML != null) {
		    PostGet = "POST";
		}
	
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest)
		{
			XMLRequest = new XMLHttpRequest();
			//XMLRequest.onreadystatechange = CrossBrowser_XMLRequestReady;
			//alert(PostGet + "\n" + trim(URL) + "\n" + new XMLSerializer().serializeToString(PostXML.documentElement));
			XMLRequest.open(PostGet, trim(URL), false);
			XMLRequest.send(PostXML);  
		}
		// branch for IE/Windows ActiveX version
		else if (window.ActiveXObject)
		{
			XMLRequest = new ActiveXObject("Microsoft.XMLHTTP");
			if (XMLRequest) {
				//XMLRequest.onreadystatechange = CrossBrowser_XMLRequestReady;
				XMLRequest.open(PostGet, trim(URL), false);
				XMLRequest.send(PostXML);
			}
		}
		//alert(XMLRequest+"\n"+XMLRequest.status+"\n"+XMLRequest.statusText+"\n"+XMLRequest.responseText+"\n\n"+PostXML)
		return XMLRequest;
	}
	catch(e)
	{return null; }	
}
//-----------------------------------------------------------------------------------------------------------------
function CrossBrowser_GetXMLObject(xmlString) {
    var xml;
    // code for IE
    if (window.ActiveXObject) {
        xml = new ActiveXObject("Microsoft.XMLDOM");
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument) {
        xml = document.implementation.createDocument("", "", null);
    }

    // code for IE
    if (window.ActiveXObject) {
        var doc = new ActiveXObject("Microsoft.XMLDOM");
        doc.async = "false";
        xml.loadXML(xmlString);
    }
    // code for Mozilla, Firefox, Opera, etc.
    else {
        var parser = new DOMParser();
        xml = parser.parseFromString(xmlString, "text/xml");
    }


    return xml;
}
//---------------------------------------------------------
function openPopupWindow(url,height,width,top,left)
{
	if(height==null || isNaN(height) || height=="" || height=="0")
		height=300;
	if(width==null || isNaN(width) || width=="" || width=="0")
		width=400;
	if(top==null || isNaN(top) || top=="")
		top=0;
	if(left==null || isNaN(left) || left=="")
		left=0;
	var win = window.open(url,'WWAdvertising',"top=" + top + "left=" + left + "height=" + height + ",width=" + width + ",status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
}

//-----------------------------------------
function cookie_create(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//-----------------------------------------
function cookie_read(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//-----------------------------------------
function cookie_erase(name) {
	cookie_create(name,"",-1);
}

//-----------------------------------------
var FlashImageIndex=0;
function FlashRender(obj)
{
    var flashsrc=obj.getAttribute("flashsrc");
    if(flashsrc!='')
    {
        var height=obj.style.height;
        var width=obj.style.width;

        var parentobj=obj.parentNode;
        var newobj=document.createElement("span");
        FlashImageIndex++;
        newobj.id="FlashObject"+FlashImageIndex;
        newobj.name=newobj.id;
        parentobj.replaceChild(newobj, obj);

	    var swfObject = new SWFObject(flashsrc, "base", width, height, "8", "#FFFFFF", true);
	    swfObject.addParam("quality", "high");
	    swfObject.addParam("wmode", "transparent");
	    swfObject.addParam("menu", "false");
	    swfObject.addParam("swLiveConnect", "true");
	    swfObject.addParam("allowScriptAccess", "sameDomain");
	    swfObject.write(newobj.id);
	}
}

//-----------------------------------------
function clearClass(objId, objName) {
    if (objId != null) {
        var obj = document.getElementById(objId);
        if(obj!=null)
            obj.className = '';
    }
    if (objName != null) {
        var objs = document.getElementsByName(objName);
        for (var i = 0; i < objs.length; i++) {
            objs[i].className = '';
        }
    }
}
//-----------------------------------------
function setClass(objId, className) {
    var obj = document.getElementById(objId);
    if(obj!=null)
        obj.className = className
}


function _ContentRating() {

    var _ContentType;
    var _MarketID;
    var _ContentID;
    var _ContentRating_SubmissionID;
    var _Container;
    var _Initial_Container;
    var _Answer_Container;
    var _Yes_Container;
    var _No_Container;
    var _IDontKnow_Container;
    var _Submiting_Container;
    var _Submited_Success_Container;
    var _Submited_Failed_Container;
    var _Feedback_SubmitButton;
    var _Answer_Code;
    var _Answer_Feedback;
    var _Answer_Feedback_RemainingChars;

    //-----------------------------------------
    this.init = _init;
    function _init(marketID, contentType, contentID) {
        _MarketID = marketID;
        _ContentType = contentType;
        _ContentID = contentID;
        _Container = document.getElementById('ContentRating_Container');
        _Initial_Container = document.getElementById('ContentRating_Initial_Container');
        _Answer_Container = document.getElementById('ContentRating_Answer_Container');
        _Yes_Container = document.getElementById('ContentRating_Yes_Container');
        _No_Container = document.getElementById('ContentRating_No_Container');
        _IDontKnow_Container = document.getElementById('ContentRating_IDontKnow_Container');
        _Submiting_Container = document.getElementById('ContentRating_Submiting_Container');
        _Submited_Success_Container = document.getElementById('ContentRating_Submited_Success_Container');
        _Submited_Failed_Container = document.getElementById('ContentRating_Submited_Failed_Container');
        _Feedback = document.getElementById('ContentRating_Feedback');
        _Answer_Feedback_RemainingChars = document.getElementById('ContentRating_Feedback_RemainingChars');
        _Feedback_SubmitButton = document.getElementById('ContentRating_Feedback_SubmitButton');
        
        _Container.style.display = '';
        _Initial_Container.style.display = '';
        TextAreaLimitor_UpdateRemainingChars(_Feedback, _Answer_Feedback_RemainingChars.id, 650)
    }

    //-----------------------------------------
    this.Answer = _Answer;
    function _Answer(code) {
        _Answer_Code = code.toUpperCase();

        _Initial_Container.style.display = 'none';
        _Yes_Container.style.display = 'none';
        _No_Container.style.display = 'none';
        _IDontKnow_Container.style.display = 'none';
        _Submiting_Container.style.display = 'none';
        _Submited_Success_Container.style.display = 'none';
        _Submited_Failed_Container.style.display = 'none';
        
        _Submiting_Container.style.display = '';
        _SubmitAnswer();
    }

    //-----------------------------------------
    this.ValidateFeedback = _ValidateFeedback;
    function _ValidateFeedback() {
        if(trim(_Feedback.value)!='')
        {
            _Feedback_SubmitButton.disabled=false;
        }
        else{
            _Feedback_SubmitButton.disabled=true;
        }
    }

    //-----------------------------------------
    this.Back = _Back;
    function _Back() {
        _Initial_Container.style.display = '';
        _Answer_Container.style.display = 'none';
        _Yes_Container.style.display = 'none';
        _No_Container.style.display = 'none';
        _IDontKnow_Container.style.display = 'none';
        _Submiting_Container.style.display = 'none';
        _Submited_Success_Container.style.display = 'none';
        _Submited_Failed_Container.style.display = 'none';
    }

    //-----------------------------------------
    this.Submit = _Submit;
    function _Submit() {
        _Answer_Feedback = _Feedback.value;

        _Answer_Container.style.display = 'none';
        _Yes_Container.style.display = 'none';
        _No_Container.style.display = 'none';
        _IDontKnow_Container.style.display = 'none';
        _Submited_Success_Container.style.display = 'none';
        _Submited_Failed_Container.style.display = 'none';

        _Submiting_Container.style.display = '';

        _SubmitFeedback();
    }

    //-----------------------------------------
    this.SubmitedFeedback = _SubmitedFeedback;
    function _SubmitedFeedback(isSuccessful) {
        _Submiting_Container.style.display = 'none';
        _Submited_Success_Container.style.display = 'none';
        _Submited_Failed_Container.style.display = 'none';
        
        if (isSuccessful) {
            _Submited_Success_Container.style.display = '';
        }
        else {
            _Submited_Failed_Container.style.display = '';
        }
    }

    //-----------------------------------------
    this.SubmitedAnswer = _SubmitedAnswer;
    function _SubmitedAnswer(isSuccessful) {
        _Submiting_Container.style.display = 'none';
        if (isSuccessful) {
            _Answer_Container.style.display = '';
            switch (_Answer_Code) {
                case "YES":
                    _Yes_Container.style.display = '';
                    break;
                case "NO":
                    _No_Container.style.display = '';
                    break;
                case "IDONTKNOW":
                    _IDontKnow_Container.style.display = '';
                    break;
            }
            _Feedback.focus();
        }
        else {
            _Submited_Failed_Container.style.display = '';
        }
    }
    //-----------------------------------------
    this.SubmitAnswer = _SubmitAnswer;
    function _SubmitAnswer() {
        var isSuccessful = false;

        var URL = "../Pages/ContentRating_SubmitAnswer.aspx?MarketID=" + _MarketID + "&ContentType=" + _ContentType + "&ContentID=" + _ContentID + "&AnswerCode=" + _Answer_Code;
        var RetXML = CrossBrowser_GetXML(URL, null);

        if (RetXML != null
            && RetXML.documentElement != null 
            && RetXML.documentElement.attributes != null 
            && RetXML.documentElement.attributes.getNamedItem("status") != null) {
            
            _ContentRating_SubmissionID='0';
            if (RetXML.documentElement.attributes.getNamedItem("ContentRating_SubmissionID") != null){
                _ContentRating_SubmissionID = RetXML.documentElement.attributes.getNamedItem("ContentRating_SubmissionID").value;
                }
                
            if (_ContentRating_SubmissionID!='0' && RetXML.documentElement.attributes.getNamedItem("status").value == "SUCCESS"){
                isSuccessful = true;
                }
        }
        window.setTimeout(function() { _SubmitedAnswer(isSuccessful); }, 1000);
    }

    //-----------------------------------------
    this.SubmitFeedback = _SubmitFeedback;
    function _SubmitFeedback() {
        var isSuccessful = false;

        if (_ContentRating_SubmissionID!='0'){
            var PostXML = CrossBrowser_GetXMLObject("<xml/>");

            PostXML.documentElement.setAttribute("feedback", _Feedback.value);

            var URL = "../Pages/ContentRating_SubmitFeedback.aspx?ContentRating_SubmissionID=" + _ContentRating_SubmissionID;
            var RetXML = CrossBrowser_GetXML(URL, PostXML);

            if (RetXML != null
                && RetXML.documentElement != null 
                && RetXML.documentElement.attributes != null 
                && RetXML.documentElement.attributes.getNamedItem("status") != null) {
                if (RetXML.documentElement.attributes.getNamedItem("status").value == "SUCCESS")
                    isSuccessful = true;
            }
            window.setTimeout(function() { _SubmitedFeedback(isSuccessful); }, 1000);
        }
    }
}


function _QuestionForum() {
    var _MarketID;
    var _Adv_QuestionForumID;
    var _UniqueID;
    var _AllowSubmissions;
    var _DatabaseAvailable;

    var _QuestionForum_SubmitQuestionTeaserButton;
    var _QuestionForum_SubmitQuestionTeaser;
    var _QuestionForum_SubmitQuestionForm;
    var _QuestionForum_SubmittingText;
    var _QuestionForum_SubmitedSuccessText;
    var _QuestionForum_SubmitedFailedText;

    var _QuestionForum_SubmitQuestionTextArea;
    var _QuestionForum_SubmitQuestionRemainingChars;

    //-----------------------------------------
    this.init = _init;
    function _init(marketID, questionForumID, uniqueID, allowSubmissions, databaseAvailable) {
        _MarketID = marketID;
        _Adv_QuestionForumID = questionForumID;
        _UniqueID = uniqueID;
        _AllowSubmissions = allowSubmissions;
        _DatabaseAvailable = databaseAvailable;
        
        _QuestionForum_SubmitQuestionTeaserButton = document.getElementById("QuestionForum_SubmitQuestionTeaserButton" + _UniqueID);
        _QuestionForum_SubmitQuestionTeaser = document.getElementById("QuestionForum_SubmitQuestionTeaser" + _UniqueID);
        _QuestionForum_SubmitQuestionForm = document.getElementById("QuestionForum_SubmitQuestionForm" + _UniqueID);
        _QuestionForum_SubmittingText = document.getElementById("QuestionForum_SubmittingText" + _UniqueID);
        _QuestionForum_SubmitedSuccessText = document.getElementById("QuestionForum_SubmitedSuccessText" + _UniqueID);
        _QuestionForum_SubmitedFailedText = document.getElementById("QuestionForum_SubmitedFailedText" + _UniqueID);
        _QuestionForum_SubmitQuestionTextArea = document.getElementById("QuestionForum_SubmitQuestionTextArea" + _UniqueID);
        _QuestionForum_SubmitQuestionRemainingChars = document.getElementById("QuestionForum_SubmitQuestionRemainingChars" + _UniqueID);
        _QuestionForum_SubmitQuestionTextArea.value = "";
        
        TextAreaLimitor_UpdateRemainingChars(_QuestionForum_SubmitQuestionTextArea, _QuestionForum_SubmitQuestionRemainingChars.id, 650)
        _SubmitQuestion_AllowSubmitCheck(_QuestionForum_SubmitQuestionTextArea);

        if (_DatabaseAvailable && _AllowSubmissions == '1') {
            _QuestionForum_SubmitQuestionTeaserButton.style.display = '';
        }

        _Questions_Init();
    }

    //-----------------------------------------
    this.SubmitQuestion_ShowForm = _SubmitQuestion_ShowForm;
    function _SubmitQuestion_ShowForm() {
        _QuestionForum_SubmitQuestionTeaserButton.style.display = 'none';
        _QuestionForum_SubmitQuestionTeaser.style.display = 'none';
        _QuestionForum_SubmitQuestionForm.style.display = '';
        _QuestionForum_SubmittingText.style.display = 'none';
        _QuestionForum_SubmitedSuccessText.style.display = 'none';
        _QuestionForum_SubmitedFailedText.style.display = 'none';
        TextAreaLimitor_UpdateRemainingChars(_QuestionForum_SubmitQuestionTextArea, _QuestionForum_SubmitQuestionRemainingChars.id, 650)
        _SubmitQuestion_AllowSubmitCheck(_QuestionForum_SubmitQuestionTextArea);
        _QuestionForum_SubmitQuestionTextArea.focus();
    }

    //-----------------------------------------
    this.SubmitQuestion_Back = _SubmitQuestion_Back;
    function _SubmitQuestion_Back() {
        _QuestionForum_SubmitQuestionTeaserButton.style.display = '';
        _QuestionForum_SubmitQuestionTeaser.style.display = '';
        _QuestionForum_SubmitQuestionForm.style.display = 'none';
        _QuestionForum_SubmittingText.style.display = 'none';
        _QuestionForum_SubmitedSuccessText.style.display = 'none';
        _QuestionForum_SubmitedFailedText.style.display = 'none';
    }

    //-----------------------------------------
    this.SubmitQuestion_Submit = _SubmitQuestion_Submit;
    function _SubmitQuestion_Submit() {
        _QuestionForum_SubmitQuestionTeaserButton.style.display = 'none';
        _QuestionForum_SubmitQuestionTeaser.style.display = 'none';
        _QuestionForum_SubmitQuestionForm.style.display = 'none';
        _QuestionForum_SubmittingText.style.display = '';
        _QuestionForum_SubmitedSuccessText.style.display = 'none';
        _QuestionForum_SubmitedFailedText.style.display = 'none';

        _SubmitQuestion_SubmitIt();
        //window.setTimeout(function() { _SubmitQuestion_SubmitIt(); }, 1000);
    }

    //-----------------------------------------
    this.SubmitQuestion_Submited = _SubmitQuestion_Submited;
    function _SubmitQuestion_Submited(isSuccessful) {
        _QuestionForum_SubmitQuestionTeaserButton.style.display = 'none';
        _QuestionForum_SubmitQuestionTeaser.style.display = 'none';
        _QuestionForum_SubmitQuestionForm.style.display = 'none';
        _QuestionForum_SubmittingText.style.display = 'none';
        _QuestionForum_SubmitedSuccessText.style.display = 'none';
        _QuestionForum_SubmitedFailedText.style.display = 'none';

        if (isSuccessful) {
            _QuestionForum_SubmitedSuccessText.style.display = '';
        }
        else {
            _QuestionForum_SubmitedFailedText.style.display = '';
        }
    }

    //-----------------------------------------
    this.SubmitQuestion_SubmitIt = _SubmitQuestion_SubmitIt;
    function _SubmitQuestion_SubmitIt() {
        var isSuccessful = false;

        var PostXML = CrossBrowser_GetXMLObject("<xml/>");
        
        PostXML.documentElement.setAttribute("question", _QuestionForum_SubmitQuestionTextArea.value);
        
        var URL = "../Pages/QuestionForum_Question_Submit.aspx?Adv_QuestionForumID=" + _Adv_QuestionForumID;
        var RetXML = CrossBrowser_GetXML(URL, PostXML);
        
        if (RetXML != null
            && RetXML.documentElement != null
            && RetXML.documentElement.attributes != null
            && RetXML.documentElement.attributes.getNamedItem("status") != null) {
            if (RetXML.documentElement.attributes.getNamedItem("status").value == "SUCCESS") {
                isSuccessful = true;
                _QuestionForum_SubmitQuestionTextArea.value = "";
            }
        }

        _SubmitQuestion_Submited(isSuccessful);
    }
    //-----------------------------------------
    this.SubmitQuestion_AllowSubmitCheck = _SubmitQuestion_AllowSubmitCheck;
    function _SubmitQuestion_AllowSubmitCheck(obj) {
        var submitbutton = document.getElementById("QuestionForum_SubmitButton"+_UniqueID);

        if ((trim(obj.value) == ""))
            submitbutton.disabled = true;
        else
            submitbutton.disabled = false;
    }
    
    //-----------------------------------------
    this.Questions_Init = _Questions_Init;
    function _Questions_Init() {
        var QuestionIDs = document.getElementsByName("Adv_QuestionForum_QuestionID" + _UniqueID);
        for (var i = 0; i < QuestionIDs.length; i++) {
            var QuestionID = QuestionIDs[i].value;
            var Question_Vote_Container = document.getElementById("Adv_QuestionForum_Question" + QuestionID + "_Vote_Container" + _UniqueID);

            if (!_DatabaseAvailable||_AllowSubmissions != '1') {
                Question_Vote_Container.style.visibility = 'hidden';
            } else {
                Question_Vote_Container.style.visibility = 'visible';

                var Vote_Checkbox = document.getElementById("Adv_QuestionForum_Question" + QuestionID + "_Vote_Checkbox" + _UniqueID);
                var Vote_ILikeItLabel = document.getElementById("Adv_QuestionForum_Question" + QuestionID + "_Vote_ILikeItLabel" + _UniqueID);
                var Vote_VoteReceivedLabel = document.getElementById("Adv_QuestionForum_Question" + QuestionID + "_Vote_VoteReceivedLabel" + _UniqueID);

                if (Vote_Checkbox.disabled || _Question_HasVote(QuestionID)) {
                    Vote_Checkbox.checked = true;
                    Vote_Checkbox.disabled = true;
                    Vote_ILikeItLabel.style.display = 'none';
                    Vote_VoteReceivedLabel.style.display = '';
                }
                else {
                    Vote_Checkbox.checked = false;
                    Vote_Checkbox.disabled = false;
                    Vote_ILikeItLabel.style.display = '';
                    Vote_VoteReceivedLabel.style.display = 'none';
                }
            }
        }
    }
    //-----------------------------------------
    this.ChangePage = _ChangePage;
    function _ChangePage(pindex) {
        var Adv_QuestionForumPageControl = document.getElementsByName("Adv_QuestionForumPageControl_" + _UniqueID);

        for (var i = 0; i < Adv_QuestionForumPageControl.length; i++) {
            var index = Adv_QuestionForumPageControl[i].getAttribute("index");
            if (index == pindex)
                Adv_QuestionForumPageControl[i].style.display = '';
            else
                Adv_QuestionForumPageControl[i].style.display = 'none';
            }
    }
    //-----------------------------------------
    this.Question_HasVote = _Question_HasVote;
    function _Question_HasVote(questionID) {
        var retval = false;
        var QFQIDValue = cookie_read("QFQID" + questionID);
        if (QFQIDValue == "1")
            retval = true;

        return retval;
    }
    //-----------------------------------------
    this.Question_Vote = _Question_Vote;
    function _Question_Vote(questionID) {
        var Vote_Checkbox = document.getElementById("Adv_QuestionForum_Question" + questionID + "_Vote_Checkbox" + _UniqueID);
        var Vote_ILikeItLabel = document.getElementById("Adv_QuestionForum_Question" + questionID + "_Vote_ILikeItLabel" + _UniqueID);
        var Vote_VoteReceivedLabel = document.getElementById("Adv_QuestionForum_Question" + questionID + "_Vote_VoteReceivedLabel" + _UniqueID);
        Vote_Checkbox.checked = true;
        Vote_Checkbox.disabled = true;
        Vote_ILikeItLabel.style.display = 'none';
        Vote_VoteReceivedLabel.style.display = '';

        _Question_Vote_SubmitIt(questionID);
        //window.setTimeout(function() { _Question_Vote_SubmitIt(questionID); }, 1);
    }

    //-----------------------------------------
    this.Question_Vote_Submited = _Question_Vote_Submited;
    function _Question_Vote_Submited(isSuccessful, questionID) {
        cookie_create("QFQID" + questionID, "1", 30);
    }

    //-----------------------------------------
    this.Question_Vote_SubmitIt = _Question_Vote_SubmitIt;
    function _Question_Vote_SubmitIt(questionID) {
        var isSuccessful = false;

        var URL = "../Pages/QuestionForum_Vote_Submit.aspx?Adv_QuestionForum_QuestionID=" + questionID;
        var RetXML = CrossBrowser_GetXML(URL, null);

        if (RetXML != null
            && RetXML.documentElement != null
            && RetXML.documentElement.attributes != null
            && RetXML.documentElement.attributes.getNamedItem("status") != null) {
            if (RetXML.documentElement.attributes.getNamedItem("status").value == "SUCCESS") {
                isSuccessful = true;
            }
        }

        if(isSuccessful)
            _Question_Vote_Submited(isSuccessful, questionID);
    }
}
//----------------------------------------------------------------
//Slider controls for scrolling boxes
var SLIDETIMER = 3;
var SLIDESPEED = 3;
var SCROLLTIMER = 3;
var SCROLLSPEED = 2;
var STARTINGOPACITY = 40;

// handles section to section scrolling of the content //
function slideContent(id, prefix, timer) {
    var div = document.getElementById(id);
    var slider = div.parentNode;
    clearInterval(slider.timer);
    slider.section = parseInt(id.replace(/\D/g, ''));
    slider.target = div.offsetTop;
    slider.style.top = slider.style.top || '0px';
    slider.current = slider.style.top.replace('px', '');
    slider.direction = (Math.abs(slider.current) > slider.target) ? 1 : -1;
    //slider.style.opacity = STARTINGOPACITY * .01;
    //slider.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
    slider.timer = setInterval(function() { slideAnimate(slider, prefix, timer) }, SLIDETIMER);
}

function slideAnimate(slider, prefix, timer) {
    var curr = Math.abs(slider.current);
    var tar = Math.abs(slider.target);
    var dir = slider.direction;
    if ((tar - curr <= SLIDESPEED && dir == -1) || (curr - tar <= SLIDESPEED && dir == 1)) {
        slider.style.top = (slider.target * -1) + 'px';
        //slider.style.opacity = 1;
        //slider.style.filter = 'alpha(opacity=100)';
        clearInterval(slider.timer);
        if (slider.autoscroll) {
            setTimeout(function() { autoScroll(slider.id, prefix, timer) }, timer * 1000);
        }
    } else {
        var pos = (dir == 1) ? parseInt(slider.current) + SLIDESPEED : slider.current - SLIDESPEED;
        slider.current = pos;
        slider.style.top = pos + 'px';
    }
}

// handles manual scrolling of the content //
function scrollContent(id, dir) {
    var div = document.getElementById(id);
    clearInterval(div.timer);
    var sections = div.getElementsByTagName('div');
    var length = sections.length;
    var limit;
    if (dir == -1) {
        limit = 0;
    } else {
        if (length > 1) {
            limit = sections[length - 1].offsetTop - div.parentNode.offsetHeight;
        } else {
            limit = sections[length - 1].offsetHeight - div.parentNode.offsetHeight + 20;
        }
    }
    //div.style.opacity = STARTINGOPACITY * .01;
    //div.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
    div.timer = setInterval(function() { scrollAnimate(div, dir, limit) }, SCROLLTIMER);
}

function scrollAnimate(div, dir, limit) {
    div.style.top = div.style.top || '0px';
    var top = div.style.top.replace('px', '');
    if (dir == 1) {
        if (Number(limit) - Math.abs(Number(top)) <= SCROLLSPEED) {
            cancelScroll(div.id);
            div.style.top = Number(limit) * -1 + 'px';
        } else {
            div.style.top = top - SCROLLSPEED + 'px';
        }
    } else {
        if (Number(Math.abs(top)) - Number(limit) <= SCROLLSPEED) {
            cancelScroll(div.id);
            div.style.top = limit + 'px';
        } else {
            div.style.top = parseInt(top) + SCROLLSPEED + 'px';
        }
    }
}

// cancel the scrolling on mouseout //
function cancelScroll(id) {
    var div = document.getElementById(id);
    //div.style.opacity = 1;
    //div.style.filter = 'alpha(opacity=100)';
    clearTimeout(div.timer);
}

// initiate auto scrolling //
function autoScroll(id, prefix, timer, restart) {
    var div = document.getElementById(id);
    div.autoscroll = (!div.autoscroll && !restart) ? false : true;
    if (div.autoscroll) {
        var sections = div.getElementsByTagName('div');
        var length = sections.length;
        div.section = (div.section && div.section < length) ? div.section + 1 : 1;
        slideContent(prefix + '-' + div.section, prefix, timer);
    }
}

// cancel automatic scrolling //
function cancelAutoScroll(id) {
    var div = document.getElementById(id);
    div.autoscroll = false;
}
//=================================================================

//-----------------------------------------
function ReallyMousingOut(evt, sEleID) {
    try {
        var iSearchDepth = 100;
        if (evt == null) { evt = window.event }

        var oEle = null;
        if (evt.toElement == null)
            oEle = evt.relatedTarget; //FireFox
        else
            oEle = evt.toElement;

        for (var i = 0; i < iSearchDepth && oEle != null; i++) {
            if (oEle.id == sEleID)
                return false;
            else {
                    oEle = oEle.parentNode;
                }

        }
    } catch (e) {return false; }
    return true;
}

//-----------------------------------------
//fly-out menus will not fly over certian objects, these functions hide the objects when fly-out menus are activated.
//which objects are hidden is a browser specific task
var WindowControl_objectTags = null;
var WindowControl_embedTags = null;
var WindowControl_Hide_Silverlight=false;
var WindowControl_Hide_Flash=false;

//hide controls for all browsers except tested/supported versions
if (browserIE || browserFirefox || browserChrome)
    WindowControl_Hide_Silverlight=false;
else
    WindowControl_Hide_Silverlight=true;

//hide controls for all browsers except tested/supported versions
if(browserIE||browserChrome)
    WindowControl_Hide_Flash=false;
else
    WindowControl_Hide_Flash=true;

//-----------------------------------------
function WindowControls_IsSilverlight(obj) {
    var isSilverlight=false;
    if(obj!=null)
    {
        var type=obj.getAttribute("type");
        if(type!=null)
           isSilverlight=(type.indexOf('silverlight')>-1)?true:false;
        else
           isSilverlight=false;
    }
    
    return isSilverlight;
}
//-----------------------------------------
function WindowControls_IsWindowless(obj,embed) {
    var isWindowless=false;
    if(obj!=null)
    {
        var param=obj.getElementsByTagName("param");
        for(var i=0;i<param.length;i++)
        {
            if(param[i].getAttribute("name")!=null&&param[i].getAttribute("name").toLowerCase()=="windowless")
            {
                if(param[i].getAttribute("value")!=null&&param[i].getAttribute("value").toLowerCase()=='true')
                {
                    isWindowless=true;
                }
            }   
        }
    }
    else if(embed!=null)
    {
        if(embed.getAttribute("windowless")!=null&&embed.getAttribute("windowless").toLowerCase()=="true")
        {
            isWindowless=true;
        }   
    }
    return isWindowless;
}

//-----------------------------------------
function WindowControls_IsTransparent(obj,embed) {
    var isTransparent=false;
    
    if(obj!=null)
    {
        var param=obj.getElementsByTagName("param");
        for(var i=0;i<param.length;i++)
        {
            if(param[i].getAttribute("name")!=null&&param[i].getAttribute("name").toLowerCase()=="wmode")
            {
                if(param[i].getAttribute("value")!=null&&param[i].getAttribute("value").toLowerCase()=='transparent')
                {
                    isTransparent=true;
                }
            }   
        }
    }
    else if(embed!=null)
    {
        if(embed.getAttribute("wmode")!=null&&embed.getAttribute("wmode").toLowerCase()=="transparent")
        {
            isWindowless=true;
        }   
    }
    return isTransparent;
}

//-----------------------------------------
function WindowControls_Hide() {
    WindowControl_objectTags = document.getElementsByTagName("object");
    WindowControl_embedTags = document.getElementsByTagName("embed");
        
    var isSilverlight=false;
    var isFlash=false;
    var isWindowless=false;
    var isTransparent=false;
    for (var i = 0; i < WindowControl_objectTags.length; i++) {
        isSilverlight=WindowControls_IsSilverlight(WindowControl_objectTags[i]);
        isFlash = (!isSilverlight) ? true : false;
        
        hideControl=false;

        if(isSilverlight&&WindowControl_Hide_Silverlight)
        {
            isWindowless=WindowControls_IsWindowless(WindowControl_objectTags[i],null);
            if(!isWindowless)
                hideControl=true;
        }
        else if(isFlash&&WindowControl_Hide_Flash){
            isTransparent=WindowControls_IsTransparent(WindowControl_objectTags[i],null);
            if(!isTransparent)
                hideControl=true;
        }
        
        if(hideControl)
        {
            if(WindowControl_objectTags[i].getAttribute("original_visibility")==null)
                WindowControl_objectTags[i].setAttribute("original_visibility", WindowControl_objectTags[i].style.visibility);
                
            WindowControl_objectTags[i].style.visibility = 'hidden';
        }
    }
    
    for (var i = 0; i < WindowControl_embedTags.length; i++) {
        isSilverlight=WindowControls_IsSilverlight(WindowControl_embedTags[i]);
        isFlash=(!isSilverlight)?true:false;

        hideControl=false;
        if(isSilverlight&&WindowControl_Hide_Silverlight)
        {
            isWindowless=WindowControls_IsWindowless(null,WindowControl_embedTags[i]);
            if(!isWindowless)
                hideControl=true;
        }
        else if(isFlash&&WindowControl_Hide_Flash){
            isTransparent=WindowControls_IsTransparent(null,WindowControl_embedTags[i]);
            if(!isTransparent)
                hideControl=true;
        }

        if(hideControl)
        {
            if (WindowControl_embedTags[i].getAttribute("original_visibility") == null)
                WindowControl_embedTags[i].setAttribute("original_visibility", WindowControl_embedTags[i].style.visibility);
                
            WindowControl_embedTags[i].style.visibility = 'hidden';
        }
    }
}
//-----------------------------------------
function WindowControls_Show() {
    WindowControl_Hide=false;
    var isFlash=false;
    var isSilverlight=(!isSilverlight)?true:false;
    var isWindowless=false;
    var isTransparent=false;

    if (WindowControl_objectTags==null)
        WindowControl_objectTags = document.getElementsByTagName("object");
    if (WindowControl_embedTags == null)
        WindowControl_embedTags = document.getElementsByTagName("embed");

    for (var i = 0; i < WindowControl_objectTags.length; i++) {
        isSilverlight=WindowControls_IsSilverlight(WindowControl_objectTags[i]);
        isFlash=(!isSilverlight)?true:false;

        showControl=false;
        if(isSilverlight&&WindowControl_Hide_Silverlight)
        {
            isWindowless=WindowControls_IsWindowless(WindowControl_objectTags[i],null);
            if(!isWindowless)
                showControl=true;
                
        }
        else if(isFlash&&WindowControl_Hide_Flash){
            isTransparent=WindowControls_IsTransparent(WindowControl_objectTags[i],null);
            if(!isTransparent)
                showControl=true;
        }
        
        if(showControl)
        {
            WindowControl_objectTags[i].style.visibility = WindowControl_objectTags[i].getAttribute("original_visibility");
        }
    }
    for (var i = 0; i < WindowControl_embedTags.length; i++) {
        isSilverlight=WindowControls_IsSilverlight(WindowControl_embedTags[i]);
        isFlash=(!isSilverlight)?true:false;

        showControl=false;
        if(isSilverlight&&WindowControl_Hide_Silverlight)
        {
            isWindowless=WindowControls_IsWindowless(null,WindowControl_embedTags[i]); 
            if(!isWindowless)
                showControl=true;
        }
        else if(isFlash&&WindowControl_Hide_Flash){
            isTransparent=WindowControls_IsTransparent(null,WindowControl_embedTags[i]);
            if(!isTransparent)
                showControl=true;
        }
        
        if(showControl)
        {
            WindowControl_embedTags[i].style.visibility = WindowControl_embedTags[i].getAttribute("original_visibility");
        }
    }
}
  function AC_Submit(){
    var ac_pageid=document.getElementById("ac_pageid");
    var ac_accesscode=document.getElementById("ac_accesscode");
    var url="../Pages/AccessCodeLogon_Submit.aspx?ac_pageid="+ac_pageid.value;

    var PostXML = CrossBrowser_GetXMLObject("<xml/>");
    PostXML.documentElement.setAttribute("AccessCode", ac_accesscode.value);

  var RetXML = CrossBrowser_GetXML(url, PostXML);
  
  var isSuccessful=false;
  var noCookies=false;
  if (RetXML != null
  && RetXML.documentElement != null
    && RetXML.documentElement.attributes != null
    && RetXML.documentElement.attributes.getNamedItem("status") != null) {
  if (RetXML.documentElement.attributes.getNamedItem("status").value == "SUCCESS")
    isSuccessful = true;
  else if (RetXML.documentElement.attributes.getNamedItem("status").value == "NOCOOKIES")
    noCookies = true;
  }
  
  if(isSuccessful){
    var ac_returnurl=document.getElementById("ac_returnurl");
    window.location=ac_returnurl.value;
  }
  else if(noCookies){
    var ac_errormessage_nocookies=document.getElementById("ac_errormessage_nocookies");
    var ac_errormessage_container=document.getElementById("ac_errormessage_container");
    ac_errormessage_container.innerHTML=ac_errormessage_nocookies.value;
  }
  else{
    var ac_errormessage=document.getElementById("ac_errormessage");
    var ac_errormessage_container=document.getElementById("ac_errormessage_container");
    ac_errormessage_container.innerHTML=ac_errormessage.value;
  }
  }
  
  //-----------------------------------------
function FlyoutMenu_On(containerid,tabid,menuid,resizeFlyout) {
    var class_off;
    var class_on;
    if(resizeFlyout==null)
        resizeFlyout=false;
        
    var tab = document.getElementById(tabid);
    if (tab != null) {
        class_off = tab.getAttribute("class_off");
        if (class_off == null || class_off=="")
            tab.setAttribute("class_off", tab.className);
            
        class_on = tab.getAttribute("class_on");
        tab.className = class_on;
    }

    var menu = document.getElementById(menuid);
    if (menu != null) {
        class_off = menu.getAttribute("class_off");
        if (class_off == null || class_off=="")
            menu.setAttribute("class_off", menu.className);
            
        class_on = menu.getAttribute("class_on");
        menu.className = class_on;
        
        var menu2 = document.getElementById(menuid+"_2");
        //this iframe allows menu to fly over flash and sliverlight controls.
        var iframe=document.getElementById(menuid+"_iframe");
        if(menu2!=null&&iframe!=null)
        {
            if(resizeFlyout&&menu2.clientWidth<tab.offsetWidth)
            {
                menu2.style.width=(tab.offsetWidth+20)+"px";
            }   

            if(resizeFlyout){
                menu2.style.left=menu.offsetWidth-menu2.clientWidth+"px";
                iframe.style.left=menu2.style.left;
            }
            var iframe_height=menu2.clientHeight-6;
            var iframe_width=menu2.clientWidth-12;
            iframe.style.height=iframe_height+"px";
            iframe.style.width=iframe_width+"px";
            iframe.style.display="block";
        }
    }
    WindowControls_Hide();
}

//-----------------------------------------
function FlyoutMenu_Off(containerid,tabid,menuid) {
    var tab = document.getElementById(tabid);
    if (tab != null) {
        tab.className = tab.getAttribute("class_off");
        }

    var menu = document.getElementById(menuid);
    if (menu != null) {
        menu.className = menu.getAttribute("class_off");

        var iframe=document.getElementById(menuid+"_iframe");
        if(iframe!=null)
        {
            iframe.style.display="none";
        }
    }
    WindowControls_Show();
}
//-----------------------------------------
function FlyoutMenu_OnMouseOut(evt, containerid,tabid,menuid) {
    if (!ReallyMousingOut(evt, containerid)) {
        return false;
    }
    else{
        FlyoutMenu_Off(containerid,tabid,menuid);
    }
}