var vLastFoc = '';

function storeCaret(textEl)
{
	if (textEl.createTextRange) 
		textEl.caretPos = document.selection.createRange().duplicate();
	
	vLastFoc = textEl;
}

function insertAtCaret(textEl, text)
{
	if(vLastFoc != '')
	{
		if (textEl.createTextRange && textEl.caretPos)
		{
			var caretPos = textEl.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		}
		else
			textEl.value  = text;
	}
}

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" : "");
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function checkCookie()
{
	if(!(getCookie('TPMediaOk')))
		document.location.href="/magic94scripts/mgrqispi94.dll?appname=WC&prgname=WC&Template=TPMCLP";
}

function TPopup(newURL,Params)
{
	if(newURL == "http://")
		return false
	else
	{
		Params1 = "toolbar=no,location=no,scrollbars=yes,top=50,left=50,resizable=1," + Params;
		TPopupWindow = window.open(newURL,"ConMan",Params1);
	}
}

function ScrollMarquee(peId)
{
	var vMsg, vMsgChar, vMar, vPaused;
	eval("vPaused = vPaused" + peId);
	
	if(vPaused == 0)
	{
		eval("vMsg = document.getElementById('cel" + peId + "').innerHTML");
		eval("vMsgChar = vMsgChar" + peId);
		eval("vMar = vMarquee" + peId);
		eval("vMarLen = vMarLen" + peId);
		
		if(vMsgChar < vMar.length)
		{
			var vtMsg = vMsg + vMar.substring(vMsgChar, vMsgChar + 1);
	
			if(vMar.substring(vMsgChar, vMsgChar + 1) == ' ')
			{
				vtMsg = vMsg + "&nbsp;";
				eval("vMsgNBs" + peId + "++");
			}
			eval("var vMsgLen = vtMsg.length - (vMarLen + (vMsgNBs" + peId + " * 5))");
	
			if(vMsgLen < 0)
				vMsgLen = 0;
	
			if(vtMsg.substring(0,5) == "&nbsp")
			{
				vMsgLen = 6;
				eval("vMsgNBs" + peId + "--");
			}
			eval("document.getElementById('cel" + peId + "').innerHTML = vtMsg.substring(vMsgLen, vMsgLen + vMarLen + (vMsgNBs" + peId + " * 5))");
	
			eval("vMsgChar" + peId + "++");
			vMsgChar++;
		}
		else
		{
			var vtMsg = vMsg + "&nbsp;";
			eval("vMsgNBs" + peId + "++");
			eval("var vMsgLen = vtMsg.length - (vMarLen + (vMsgNBs" + peId + " * 5))");
	
			if(vMsgLen < 0)
				vMsgLen = 0;
	
			if(vtMsg.substring(0,5) == "&nbsp")
			{
				vMsgLen = 6;
				eval("vMsgNBs" + peId + "--");
			}
			eval("document.getElementById('cel" + peId + "').innerHTML = vtMsg.substring(vMsgLen, vMsgLen + vMarLen + (vMsgNBs" + peId + " * 5))");
			eval("vMsgSpaces" + peId + "++");
		}
		eval("var vMsgSpaces = vMsgSpaces" + peId);
		eval("var vMarBSpc = vMarBSpc" + peId);
			
		if(vMsgSpaces >= vMarBSpc)
		{
			eval("vMsgSpaces" + peId + " = 0");
			eval("vMsgChar" + peId + " = 0");
		}
	}
	eval("window.setTimeout('ScrollMarquee(" + peId + ")',vMarSpd" + peId + ")");
}

function Is()
{
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 2));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns5 = (this.ns && (this.major > 4));
	this.ns6 = (this.ns && (agent.indexOf('netscape6')!=-1) );
	this.ns7 = (this.ns && (agent.indexOf('netscape/7')!=-1) );
	this.ns7pr = (this.ns && (agent.indexOf('netscape/7.0b1')!=-1) );
	this.ns71 = (this.ns && (agent.indexOf('netscape/7.1')!=-1) );
	this.ie = (agent.indexOf("msie") != -1);
	this.ie3 = (this.ie && (this.major == 2));
	this.ie4 = (this.ie && (this.major >= 4));
	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
	this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1));
	this.op3 = (agent.indexOf("opera") != -1);
	this.pc  = (agent.indexOf("win") != -1);
	this.mac = (agent.indexOf("mac")!=-1); // Mac detect
	this.moz = ( this.ns && (agent.indexOf("netscape/") == -1) );
	if (this.moz) this.ns = 0;
}

var is = new Is();

function dr(sHtml) {
	document.write(sHtml);
}

function Flash(sPath, nHeight, nWidth)
{
    vAllowScript = "sameDomain";


    return (
        "<object type=\"application/x-shockwave-flash\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" data=\"" + sPath + "\" width=\"" + nWidth + "\" height=\"" + nHeight + "\" allowScriptAccess=\"" + vAllowScript + "\" style=\"VISIBILITY:VISIBLE; ZINDEX:1\">"
            + "<param name=\"menu\" value=\"false\">"
            + "<param name=\"movie\" value=\"" + sPath + "\">"
            + "<param name=\"quality\" value=\"high\">"
            + "<param name=\"wmode\" value=\"transparent\">"
	    + "<param name=\"allowScriptAccess\" value=\"sameDomain\">"
        + "</object>"
	
    );
}



