//flashproxy




function connectToFlash() {
    if (arguments.length > 0)
    {
        var justArgs = new Array();
        for (var i = 0; i < arguments.length; ++i)
        {
            justArgs.push(arguments[i]);
        }

		var theFlashProxy = new FlashProxy(lcId, 'top', 'layouts/js/JavaScriptFlashGateway.swf', null);
        theFlashProxy.call( justArgs[0], justArgs[1]);
    }
	//flashProxy.call("addItem", {label:selectList.options[index].text, data:selectList.options[index].value});
}

function executeFromFlash(){
	if(arguments[1] == 'MenuDisplayAt'){
		openobjHTTP('MenuDisplayAt', 'cmsleft', 'parents', arguments[0])	
	}
	/*for(var ar=0; ar < arguments.length; ar++){
		alert('arguments[' + ar + '] = ' + arguments[ar]);
	}*/
}

///flashproxy end


var objHTTP=false;
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  objHTTP = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   objHTTP = false;
  }
 }

if (!objHTTP && typeof XMLHttpRequest != 'undefined') {
  objHTTP = new XMLHttpRequest();
}

function openobjHTTP(eventname, place, idname, id){
	if(idname != undefined){
		querystr = '&' + idname + '=' + id;
	}else{
		var querystr = '';
	}
	if(place == 'self'){
		document.location = 'index.cfm?event=' + eventname + querystr;
	}else{
		objHTTP.open('GET','index.cfm?event=' + eventname + querystr ,false)
		objHTTP.send('go' + eventname + querystr + place);
		if(objHTTP.status == '200' && objHTTP.statusText == 'OK'){
			var x = objHTTP.responseText;
			if(location.href.indexOf('debugjs') == -1){
				 pos = x.indexOf('<object');
				 if(pos == -1){
					 pos = x.indexOf('<embed');
					 eindpos = x.indexOf('</embed>');
					  x = x.substring(pos, eindpos + 7);		
				 }else{
					
					 eindpos = x.indexOf('</object>');
					 x = x.substring(pos, eindpos + 9);		
				 }
		     }
			 document.getElementById(place).innerHTML = x;
			   
	
		}
	}
}
function RemoveHTML( strText, regEx )
{
	
	return strText.replace(regEx, "");
}



function replaceSt(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceSt(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}



function openWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

