var cm8Host = "rmm1u.checkm8.com";
/*function writeCM8Log(eventStr)
{
	if(typeof(writeToLog)!="undefined")
		writeToLog(eventStr);
}*/
if(typeof(writeCM8Log)!="undefined")
		writeCM8Log("E1-S");
if(typeof(TheWindow)=="undefined")
   TheWindow = window;
function getHourStr()
{
   	var theDate = new Date();	
	var HH;		
  	HH = new String(theDate.getHours());
	if(HH < 0 || HH > 24)
	{
		HH = 1;
	}
	
	if(HH.length < 2)
		HH = "0" + HH;
    return HH;
}
function getServiceHost()
{
	return "SERVICEHOST=" + cm8Host;
}
function getDateStr()
{
  	var theDate = new Date();	
	var retTime;

	var YYYY;	 
	var DD;		 

	var HH_GMT;  
	var dif ;
	YYYY = new String(theDate.getYear());
	dif = 4 - YYYY.length;
	
	if(dif > 0)
	{
		for(i=0;i<dif;i++)
		{
			YYYY = "0" + YYYY;
		}
	}
	MM = new String(theDate.getMonth()+1);

	if(MM < 1 || MM > 12)
	{
		MM = 1;
	}

	if(MM.length < 2)
		MM = "0" + MM;
	

	DD = new String(theDate.getDate() );
	if(DD < 1 || DD > 31)
	{
		DD = 1;
	}
	
	if(DD.length < 2)
		DD = "0" + DD;
		
   return YYYY + MM + DD;

}
function getUserTime()
{  
	retTime = new String("DATE=" + getDateStr() + "&HOUR=" + getHourStr());	
	return retTime;
}
function isFrames()
{
return (agt.indexOf("win")!=-1  && window.parent && window.parent.frames &&
		   window.parent.frames.length >= 2 && 
		   typeof(window.parent.document) != 'unknown'&&typeof(window.parent.document.body.clientWidth)!='undefined')
}
function getScreenWidth()
{
	var s = "WIDTH=";
	val=1024;
	if (is_ie)
	{
		if(isFrames())
		{
			if (window.parent.document.documentElement.clientWidth > 0)
				val=window.parent.document.documentElement.clientWidth;
			else
				val=window.parent.document.body.clientWidth;
		}
		if(typeof(TheWindow.document.body.clientWidth)!='undefined' || typeof(TheWindow.document.documentElement.clientWidth)!='undefined')
		{
			if (TheWindow.document.documentElement.clientWidth > 0)
				val=TheWindow.document.documentElement.clientWidth;
			else
				val=TheWindow.document.body.clientWidth;
		}
	}
	else if(is_nav&&typeof(TheWindow.innerWidth)!='undefined')
		val=TheWindow.innerWidth;
	return s+val;
}


function getScreenHeight()
{
	s = "HEIGHT=";
	val="768";
	if (is_ie)
	{
		if(isFrames())
		{
			if (window.parent.document.documentElement.clientHeight > 0)
				val=window.parent.document.documentElement.clientHeight;
			else
				val=window.parent.document.body.clientHeight;
		}
		if(typeof(TheWindow.document.body.clientHeight)!='undefined' || typeof(TheWindow.document.documentElement.clientHeight)!='undefined')
		{
			if (TheWindow.document.documentElement.clientHeight > 0)
				val=TheWindow.document.documentElement.clientHeight;
			else
				val=TheWindow.document.body.clientHeight;
		}
	}
	else if(is_nav&&typeof(TheWindow.innerHeight)!='undefined')
		val=TheWindow.innerHeight;
	return s+val;
}

function getFontSize()
{
	s = "FONTSIZE=";
	if(is_ie &&  agt.indexOf("win")!=-1)
	{
		TheWindow.document.body.insertAdjacentHTML("afterBegin" ,'<span  style="position:absolute; visibility:hidden;"  id="cm8textSize">_</span>');
		if(typeof(document.all.cm8textSize)!='undefined'&&typeof(document.all.cm8textSize.offsetWidth)!='undefined')
		 return s+document.all.cm8textSize.offsetWidth;
		else
		{
  		 return s+8;
		}
	}
	else
	{
		return s+10;
	}
}

function getTheUrl(catParam)
{
	
	var s = "URL=";
	var dom="";
	if(location.href.indexOf("file")!=0)
	  dom = document.domain;
	if((ind = dom.indexOf(":")) != -1)
		dom = dom.substring(0 , ind);
	if (typeof(catParam) != 'undefined' )
		return s+dom+"@"+catParam;
	else
	{
		return s+escape(window.location);
	}
}

function getKeyword()
{
	var s = "KEYWORD=";
	if(typeof(cm8keyword) != 'undefined')
		s += cm8keyword;
	else if(typeof(keyword) != 'undefined')
		s += keyword;
	return s;
}



function getPageView()
{
    if(typeof(pageView) == 'undefined')
	 pageView=(new Date().getTime());
	s = "page="+pageView;
	return s;
}
agt=navigator.userAgent.toLowerCase();

var cm8CD = "";
appVer = navigator.appVersion.toLowerCase();
iePos  = appVer.indexOf('msie');
is_ie   = (iePos!=-1);
is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1));

function createObject(objStr)
{
	try
	{
		obj1 = new ActiveXObject(objStr);
		if(obj1) return obj1;
	}
	catch(err){};
	
	return false;
}

function cm8IsObject(objStr)
{
//	var obj1=false;
//	eval("try{obj1=typeof(new ActiveXObject(objStr))=='object';}catch(err){}");
//	return obj1;
	return true;
}

if(appVer.indexOf('msie')>-1&&agt.indexOf("win")>-1)
{
  /*document.write('<SCR'+'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('te1 = IsObject(CreateObject("ScriptBridge.ScriptBridge")) \n');
  document.write('te2 = IsObject(CreateObject("MSComctlLib.Slider")) \n');
  document.write('te3 = IsObject(CreateObject("ScriptBridge.ScriptBridge.1")) \n');
  document.write('</SCR'+'IPT\> ');
  */
    te1 = cm8IsObject("ScriptBridge.ScriptBridge");
	te2 = cm8IsObject("MSComctlLib.Slider");
	te3 = cm8IsObject("ScriptBridge.ScriptBridge.1");
}
else
{
  te1=true;
}
function isActivexE()
{
   
/*   if(typeof(te1)=="undefined")
     te1=false;
   if(typeof(te2)=="undefined")
     te2=false;
   if(typeof(te3)=="undefined")
     te3=false;
	 */
  if(te1||te2||te3)
   return "1";
  return "0";
}
function getActivexEnabled()
{
  return "AX="+isActivexE();
  
}			
cm8CD =   getScreenWidth() + "&" + getScreenHeight() + "&" + getUserTime();
cm8CD+= "&" + getFontSize();
cm8CD +=  "&" + getKeyword();
//cm8CD +=  "&" + getPageView();
cm8CD +=  "&" + getServiceHost();
cm8CD+= "&" + getActivexEnabled();

var iframeOL = null; 
if(typeof(cm8iframe) != 'undefined')
{
   iframeOL =  window.onload;
   window.onload=doIframeLoad;
}

function doIframeLoad()
{
  
	if(iframeOL)
		iframeOL();	
    contStr="<iframe width='0' height='0'  style='position:absolute;width:0;height:0' src='"+cm8iframe+"'></iframe>";
    document.body.insertAdjacentHTML("afterBegin" , contStr);

}

function cm8GetProtocol()
{
  var prot=document.location.protocol;
  if(prot.indexOf("https")!=-1)
   return "https";
  return "http";
}
var CM8UseDefer = false;
if ((typeof(CM8DisableDefer) == "undefined") ||
    ((CM8DisableDefer.toString().toLowerCase() != "yes") &&
	 (CM8DisableDefer.toString().toLowerCase() != "true"))) {
	if (typeof(document.getElementsByTagName)!='undefined') {
		var tag=document.getElementsByTagName('BODY').item(0);
		if (typeof(tag.insertAdjacentHTML) != 'undefined')
			CM8UseDefer = true;
		else if ((typeof(tag.insertBefore) != 'undefined') && (typeof(document.createRange) != 'undefined')) {
			var r = document.createRange();
			if ((typeof(r.setStartAfter) != 'undefined') &&
				(typeof(r.createContextualFragment) != 'undefined'))
				CM8UseDefer = true;
		}
	}
}

function CM8TransplantJSFile(url)
{
    	var scriptTag = document.createElement("SCRIPT");
		scriptTag.src = url+"&tag=den";
		scriptTag.defer=true;
		document.body.appendChild(scriptTag);
  
}
function RMCM8ShowAd(str,categ)
{
  if(typeof(categ) == 'undefined')
	 categ="";
  if(str!="" && str.charAt(str.length-1)!="&" && str.charAt(str.length-1)!="?")
     str+="&";
	 

  //document.write("<scr" + "ipt  language=javascript src='checkm8_init_v3IEDEFER.js'></scr" + "ipt>"); 
	
//document.write("<scr" + "ipt defer language=javascript src='"+str+cm8CD+ "&" + getTheUrl(categ) +"'></scr" + "ipt>");
	CM8UseDefer = false;
    if(!CM8UseDefer)
	{
    	document.write("<scr" + "ipt  language=javascript src='"+str+cm8CD+ "&" + 							
			getTheUrl(categ) +"'></scr" + "ipt>"); 
	}
	else
	{
		window.setTimeout("CM8TransplantJSFile('"+str+cm8CD+ "&" + getTheUrl(categ) +"')", 0); 
	}
}
if(typeof(cm8cat) != 'undefined')
    RMCM8ShowAd(cm8GetProtocol()+"://"+cm8Host+"/RMM/detect?",cm8cat);
	
	
if(typeof(writeCM8Log)!="undefined")
		writeCM8Log("E1-E");

		
