﻿// <![CDATA[
/*
    WEBPART EDITOR & CATALOG
*/
//SET_DHTML(CURSOR_MOVE, RESIZABLE, NO_ALT, SCROLL, "alligator", "bluelyr"+TRANSPARENT, "button"+VERTICAL+HORIZONTAL+CURSOR_DEFAULT, "cat"+TRANSPARENT, "chameleon", "counter", "greylyr"+TRANSPARENT, "koala", "leop", "low", "muckl"+TRANSPARENT+COPY+4, "prdog", "redarrow", "reldiv", "reldivn4", "reldiv2"+TRANSPARENT, "reldiv2n4"+TRANSPARENT, "reltab", "sepline1"+NO_DRAG, "slidercanvas", "smile1"+SCALABLE, "thumb"+HORIZONTAL+MAXOFFLEFT+45+MAXOFFRIGHT+45, "track"+NO_DRAG, "tryit", "upleft");
//SET_DHTML(CURSOR_MOVE,"zEditLayer","zCatalogLayer");
  
    
/*
    TV GUIDE DETAIL PAGE
*/
/*function cleanstring(str)
{
    var mystr;
    var i;
    
    for (i = 0; i <= str.length; i++)
    {
        mystr = str.split("'").join("\'");
        alert(mystr);
    }
    return mystr;
}*/


/*
    ASYNC PROCESS
*/
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
var postBackElement='';
var oldPostBackElement='';
var pQueue = new Array();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
   if (args.get_error() !=undefined)
   {
       if ((args.get_response().get_statusCode() == '12007') || (args.get_response().get_statusCode() == '12029'))
       {
        //Show a Message like 'Please make sure you are connected to internet';
     
        args.set_errorHandled(true); 
       }
          args.set_errorHandled(true); 
   }
}

function InitializeRequest(sender, args)
   {
    
      postBackElement = args.get_postBackElement();
      if (prm.get_isInAsyncPostBack())
            {
            pQueue.push(postBackElement.name);
            args.set_cancel(true);
            }   
        else
            {
           // pQueue.push(postBackElement.name);
            oldPostBackElement= postBackElement.name;
            args.set_cancel(false);
            }
   }

function EndRequest(sender, args)
   {
   
    var x =sender.toString();

   //REMOVE THE COMPLETED PROCESS
   var idx=0;
   for (i=0;i<pQueue.length;i++)
    {
    if (pQueue[i]==oldPostBackElement)
        {
        pQueue.splice(i,1);
        break;
        }
    }
   
   //EXECUTE THE NEXT PROCESS
   if (pQueue.length>0)
        {
        __doPostBack(pQueue[0],'');
        pQueue.splice(0,1);
        }   

   
   }

function inProcess(v)
    {
    var ret=false;
     for (i=0;i<pQueue.length;i++)
        {
        if (postBackElement.id!=v)
            {
            ret=false;
            }
        else
            {
            return true;
            }
        }

    return ret; 
    }      
      
//EXECUTE ON LOAD!!!
try
{
    var m=MCT;
//     DomReady.ready(function() {
//                   MCT.raiseFunctionOnLoad();MCT.raiseEventOnLoad();
//                });

window.onload = function () {MCT.raiseFunctionOnLoad();MCT.raiseEventOnLoad(); };
}
catch (e)
{
}


// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
// ]]>