var itl_x;
var itl_dx=0;
var itl_objId="itlMasterDiv";
var itl_objLeftLimit;
var itl_objInitX=0;
var itl_objOffSetX=0;
var itl_acceptWheelInput=true;
var itl_driftLock=false;
var IE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;

var ic0Flag=true;
var ic1Flag=true;
var ic2Flag=true;
var ic3Flag=true;
var ic4Flag=true;
var ic5Flag=true;
var ic6Flag=true;
var ic7Flag=true;
var ic1msg1, ic2msg1, ic2msg2, ic2msg3, ic5msg1, ic5msg2, ic7msg1, ivStr;

function itl_varInit() {
	var lastEntry=document.getElementById('itlLastEntry').innerHTML;
	if (lastEntry=="") var lastEntryPos=8000;
	else var lastEntryPos=document.getElementById(lastEntry).offsetLeft;
	if (lastEntryPos<8000) lastEntryPos=8000;
	itl_objLeftLimit=(document.documentElement.clientWidth/2)-lastEntryPos;
	hookEvent("itlMasterDiv","mousewheel",itl_wheelMovementX);
}
function hookEvent(element, eventName, callback) {
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.addEventListener)
  {
    if(eventName == 'mousewheel')
      element.addEventListener('DOMMouseScroll', callback, false);  
    element.addEventListener(eventName, callback, false);
  }
  else if(element.attachEvent)
    element.attachEvent("on" + eventName, callback);
}
function unhookEvent(element, eventName, callback) {
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.removeEventListener)
  {
    if(eventName == 'mousewheel')
      element.removeEventListener('DOMMouseScroll', callback, false);  
    element.removeEventListener(eventName, callback, false);
  }
  else if(element.detachEvent)
    element.detachEvent("on" + eventName, callback);
}
function cancelEvent(e) {
	e=e?e:window.event;
	if (e.stopPropagation)
		e.stopPropagation();
	if (e.preventDefault)
		e.preventDefault();
	e.cancelBubble=true;
	e.cancel=true;
	e.returnValue=false;
	return false;
}
function itl_wheelMovementX(e) {
	e=e?e:window.event;
	var wheelData=e.detail?e.detail*-1:e.wheelDelta/40;
	if (itl_acceptWheelInput) {
		itl_acceptWheelInput=false;
		itl_wheelMovementXProcess(5,10*wheelData)
	}
	return cancelEvent(e);
}
function itl_wheelMovementXProcess(i, dx) {
	itl_driftLock=true;
	var itl_objx=document.getElementById(itl_objId).offsetLeft;
	if ((itl_objx+dx)<(itl_objLeftLimit+itl_objOffSetX)) {
		document.getElementById(itl_objId).style.left=(itl_objLeftLimit+itl_objOffSetX)+"px";
		i=0;
	} else if ((itl_objx+dx)>(itl_objInitX+itl_objOffSetX)) {
		document.getElementById(itl_objId).style.left=(itl_objInitX+itl_objOffSetX)+"px";
		i=0;
	} else {
		document.getElementById(itl_objId).style.left=(itl_objx+dx)+"px";
	}
	if (i>0) {
		setTimeout("itl_wheelMovementXProcess("+(i-1)+","+dx+")",25);
	} else {
		itl_acceptWheelInput=true;
		itl_driftLock=false;
		setTimeout("itl_drift("+25+","+dx+")",25);
	}
}
function itl_endMovement() {
	document.onmousemove=null;
	document.onmouseup=null;
	itl_driftLock=false;
	itl_drift(25,itl_dx);
	itl_dx=0;
}
function itl_startMovementX(e) {
	if (IE) {
		event.returnValue=false;
		itl_x=event.clientX+document.documentElement.scrollLeft;
	} else {
		e.preventDefault();
		itl_x=e.pageX;
	}
	itl_driftLock=true;
	document.onmousemove=itl_moveObjX;
	document.onmouseup=itl_endMovement;
}
function itl_moveObjX(e) {
	if (IE) {
		itl_dx=event.clientX+document.documentElement.scrollLeft-itl_x;
		itl_x=event.clientX+document.documentElement.scrollLeft;
	} else {
		itl_dx=e.pageX-itl_x;
		itl_x=e.pageX;
	}
	
	var itl_objx=document.getElementById(itl_objId).offsetLeft;
	if ((itl_objx+itl_dx)<(itl_objLeftLimit+itl_objOffSetX)) {
		document.getElementById(itl_objId).style.left=(itl_objLeftLimit+itl_objOffSetX)+"px";
	} else if ((itl_objx+itl_dx)>(itl_objInitX+itl_objOffSetX)) {
		document.getElementById(itl_objId).style.left=(itl_objInitX+itl_objOffSetX)+"px";
	} else {
		document.getElementById(itl_objId).style.left=(itl_objx+itl_dx)+"px";
	}
}
function itl_drift(i,factor) {
	if (i>0 && !itl_driftLock && factor!=0) {
		var itl_objx=document.getElementById(itl_objId).offsetLeft;
		if (factor>0) var delta=Math.ceil(factor*(i/(50-i)));
		else var delta=Math.floor(factor*(i/(50-i)));
		if ((itl_objx+delta)<(itl_objLeftLimit+itl_objOffSetX)) {
			document.getElementById(itl_objId).style.left=(itl_objLeftLimit+itl_objOffSetX)+"px";
		} else if ((itl_objx+delta)>(itl_objInitX+itl_objOffSetX)) {
			document.getElementById(itl_objId).style.left=(itl_objInitX+itl_objOffSetX)+"px";
		} else {
			document.getElementById(itl_objId).style.left=(itl_objx+delta)+"px";
			setTimeout("itl_drift("+(i-1)+","+(factor)+")",50);
		}
	}
}

/*****************************************************************************************************************/
function indexVarInit(vStr, c1msg1, c2msg1, c2msg2, c2msg3, c5msg1, c5msg2) {
	ivStr=vStr;
	ic1msg1=c1msg1;
	ic2msg1=c2msg1;
	ic2msg2=c2msg2;
	ic2msg3=c2msg3;
	ic5msg1=c5msg1;
	ic5msg2=c5msg2;
	icPohInit();
	if (!IE) {
		setTimeout("icFadeIn(\'ic1Div\',"+1+","+10+")",0);
		setTimeout("icFadeIn(\'icPohDiv\',"+1+","+10+")",200);
		setTimeout("icFadeIn(\'icPromo1Div\',"+1+","+10+")",400);
		setTimeout("icFadeIn(\'ic4Div\',"+1+","+10+")",600);
		setTimeout("icFadeIn(\'ic6Div\',"+1+","+10+")",800);
		setTimeout("icFadeIn(\'ic5Div\',"+1+","+10+")",1000);
		setTimeout("icFadeIn(\'ic2Div\',"+1+","+10+")",1200);
		setTimeout("icFadeIn(\'icCallDiv\',"+1+","+10+")",1400);
	}
}
function indexPromptSignUp(title) {
	 promptSignUp=function() {
		if (!document.getElementById('maskContentDiv')) signUp(title);
	}
	setTimeout("promptSignUp()",7000);
}
function icPohInit() {
	var str=pohContentArray[pohIndex]+pohContentArray[pohIndex-1]+pohContentArray[pohIndex-2]+pohContentArray[pohIndex-3]+pohContentArray[pohIndex-4]+pohContentArray[pohIndex-5]+pohContentArray[pohIndex-6];
	document.getElementById('icPohSlideDiv').innerHTML=str;
	if (document.getElementById('ipoh'+pohIndexArray[pohIndex]).filters) document.getElementById('ipoh'+pohIndexArray[pohIndex]).filters.alpha.opacity=0;
	else document.getElementById('ipoh'+pohIndexArray[pohIndex]).style.opacity=0;
	setTimeout("icPohSlide(9)",5000);
}
function icPohIndexGen(offset) {
	if ((pohIndex-offset)<0) return pohIndex-offset+pohIndexMax+1;
	else return pohIndex-offset;
}
function icPohRun() {
	if (pohIndex==pohIndexMax) pohIndex=0;
	else pohIndex++;
	var str=pohContentArray[pohIndex]+pohContentArray[icPohIndexGen(1)]+pohContentArray[icPohIndexGen(2)]+pohContentArray[icPohIndexGen(3)]+pohContentArray[icPohIndexGen(4)]+pohContentArray[icPohIndexGen(5)]+pohContentArray[icPohIndexGen(6)];
	document.getElementById('icPohSlideDiv').style.top=-38+"px";
	document.getElementById('icPohSlideDiv').innerHTML=str;
	if (document.getElementById('ipoh'+pohIndexArray[pohIndex]).filters) document.getElementById('ipoh'+pohIndexArray[pohIndex]).filters.alpha.opacity=0;
	else document.getElementById('ipoh'+pohIndexArray[pohIndex]).style.opacity=0;
	setTimeout("icPohSlide(9)",5000);
}
function icPohSlide(i) {
	document.getElementById('icPohSlideDiv').style.top=-38+Math.round(77/10*(10-i))+"px";
	if (i>0) {
		setTimeout("icPohSlide("+(i-1)+")",50);
	} else {
		setTimeout("icFadeIn(\""+'ipoh'+pohIndexArray[pohIndex]+"\","+1+","+10+")",50);
		setTimeout("icPohRun()",500);
	}
}
function icDivMorph(icDivId, toW, toH, speed, callback) {
	var cW=document.getElementById(icDivId).clientWidth;
	var cH=document.getElementById(icDivId).clientHeight;
	if (cW!=toW || cH!=toH) {
		var dW=toW-cW;
		var dH=toH-cH;
		var t=Math.abs(Math.round(dW/(20*speed)));
		var t2=Math.abs(Math.round(dH/(20*speed)));
		if (t<t2) t=t2;
		if (t==0) t=1;
		icDivMorphProcess(icDivId, t,1,cW,cH,dW,dH,callback);
	}
}
function icDivMorphProcess(icDivId, t, i, cW, cH, dW, dH, callback) {
	document.getElementById(icDivId).style.width=cW+Math.round(dW/t*i)+"px";
	document.getElementById(icDivId).style.height=cH+Math.round(dH/t*i)+"px";
	document.getElementById(icDivId).style.backgroundPosition="center";
	if (i<t) setTimeout("icDivMorphProcess(\'"+icDivId+"\',"+t+","+(i+1)+","+cW+","+cH+","+dW+","+dH+",\'"+callback+"\')", 50);
	else {
		if (typeof(callback)!='undefined') eval(callback);
	}
}
function icDivShrink(icDivId) {
	var str;
	if (icDivId=="ic0") str=ic0msg1;
	else if (icDivId=="ic1") str=ic1msg1;
	else if (icDivId=="ic2") str=ic2msg1;
	else if (icDivId=="ic3") str=ic3msg1;
	else if (icDivId=="ic4") str=ic4msg1;
	else if (icDivId=="ic5") str=ic5msg1;
	else if (icDivId=="ic6") str=ic6msg1;
	document.getElementById(icDivId).innerHTML="<div class='iObjTitle'>"+str+"</div>";
	icDivMorph(icDivId,260,500,1,"icDivShrinkCallBack(\""+icDivId+"\")");
}
function icDivShrinkCallBack(icDivId) {
	if (icDivId=="ic0") ic0Flag=true;
	else if (icDivId=="ic1") ic1Flag=true;
	else if (icDivId=="ic2") ic2Flag=true;
	else if (icDivId=="ic3") ic3Flag=true;
	else if (icDivId=="ic4") ic4Flag=true;
	else if (icDivId=="ic5") ic5Flag=true;
	else if (icDivId=="ic6") ic6Flag=true;
}
function icFadeIn(divId, i, t) {
	if (document.getElementById(divId).filters) document.getElementById(divId).filters.alpha.opacity=(i/t)*100;
	else document.getElementById(divId).style.opacity=(i/t);
	if (i<t) setTimeout("icFadeIn(\'"+divId+"\',"+(i+1)+","+t+")",50);
}
function ic1Play() {
	if (ic1Flag) {
		ic1Flag=false;
		icDivMorph("ic1",633,500,1,"ic1CallBack()")
	}
}
function ic1CallBack() {
	var str="";
	str+="<div style='position:relative;'><div class='prevS' style='position:absolute;right:3px;top:3px;' onClick='icDivShrink(\"ic1\")'></div>"+embedYouTube(ivStr,633,500,1,0)+"</div>";
	document.getElementById('ic1').innerHTML=str;
}
function ic2Play() {
	if (ic2Flag) {
		ic2Flag=false;
		icDivMorph("ic2",700,500,1,"ic2CallBack()")
	}
}
function ic2CallBack() {
	var str="";
	str+="<div style='height:100%;width:100%;background-image:url(/img/transfill_mild.png);'>";
		str+="<div class='aWhite' style='padding:3px 0 0 5px;font-size:1.5em;font-weight:bold;float:left;'>"+ic2msg1+"</div>";
		str+="<div class='prevS' style='float:right;margin:3px 3px 0 0;' onClick='icDivShrink(\"ic2\")'></div>";
		str+="<div id='ic2InfoDiv' class='aWhite' style='clear:both;font-size:0.9em;font-weight:bold;padding:20px;opacity:0;filter:alpha(opacity=0);'>"+ic2msg2+"<br /><br />"+ic2msg3+"</div>";
	str+="</div>";
	document.getElementById('ic2').innerHTML=str;
	setTimeout("icFadeIn(\'ic2InfoDiv\',"+1+","+10+")",100);
}
function ic5Play() {
	if (ic5Flag) {
		ic5Flag=false;
		icDivMorph("ic5",500,500,1,"ic5CallBack()")
	}
}
function ic5CallBack() {
	var str="";
	str+="<div style='height:100%;width:100%;background-image:url(/img/transfill_mild.png);'>";
		str+="<div class='aWhite' style='padding:3px 0 0 5px;font-size:1.5em;font-weight:bold;float:left;'>"+ic5msg1+"</div>";
		str+="<div class='prevS' style='float:right;margin:3px 3px 0 0;' onClick='icDivShrink(\"ic5\")'></div>";
		str+="<div id='ic5InfoDiv' style='padding:20px 10px;height:400px;clear:both;"+(IE?"":"opacity:0;")+"'></div>";
		str+="<div style='font-size:1.1em;font-weight:bold;padding:0 10px 0 10px;text-align:right;'><a class='sia' href='/blog/b.php?blog=new'>"+ic5msg2+" &#187;</a></div>";
	str+="</div>";
	document.getElementById('ic5').innerHTML=str;
	startRequest("/index/popbloglist.php","","ic5CallBackRA(xmlhttp.responseText)");
}
function ic5CallBackRA(rText) {
	document.getElementById('ic5InfoDiv').innerHTML=rText;
	if (!IE) setTimeout("icFadeIn(\'ic5InfoDiv\',"+1+","+10+")",100);
}