// JavaScript Document
var isIna=true;
var toShow=Array('flashcntrl');
var oAjx = null;
var noflash=(isIna ? '<span class="noflash">Anda perlu <em>flash player</em> untuk melihat flash bagian ini <a href="http://www.macromedia.com/go/getflashplayer" class="noflashlnk" target="_blank">klik di sini</a> untuk mendapatkannya</span>' : '<span class="noflash">You need flash player to see this part, <a href="http://www.macromedia.com/go/getflashplayer" class="noflashlnk" target="_blank">click here</a> to download');

function objAjx() {
    var ro = null;
	if (typeof XMLHttpRequest != "undefined") {
		ro = new XMLHttpRequest();
	} 
	else {
		try {ro = new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e) {
			try {ro = new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e) {
			}
		}
	}
	return ro;
}

function doNothing( ) {
	return true;
}

function msg(cMsg){
	if (!cMsg){
		cMsg = (isIna ? "Proses tidak bisa diteruskan, terjadi error!" : "An error occurs, current process has stopped");
	}
	alert(cMsg);
}

function onloadJob(){
	for (i=0; i<toShow.length; i++)	{
		o=byId(toShow[i]);
		o.style.display='';
	}
	oAjx = objAjx();
	(byId('holitv')).innerHTML=noflash;
	shHdEntertain('','',1);
	dTest = byId('main_content_left');
	dTestX = byId('main_content_right');
	if (typeof(dTest.offsetHeight) != 'undefined')	{
		dOH = dTest.offsetHeight;
		dxOH= dTestX.offsetHeight;
		if (dOH < 500 && dxOH < 500) {
			dTest.style.height="500px";
			dTestX.style.height="500px";
		}
		else {
                    if (dxOH < dOH) {
                          dTestX.style.height=dOH+"px";
                    } else {
                        if (dOH < dxOH){
                                dTest.style.height=dxOH+"px";
                        }
		    }
		}
		
	}
}

function byId(id){
	return (document.getElementById(id) ? document.getElementById(id) : false);
}

function shHdEntertain(t,obj,dontWarn){
	t=(!t ? 2 : t); 
	obj = (!obj ? 'holitvhold' : obj);
	istv=(obj=='holitvhold' ? true : false);
	
	o = byId(obj);
	if (o)	{
		file=(istv ? 'http://holianaa.or.id/images/journeytoholiv2.swf' : 'http://holianaa.or.id/images/headermusic.swf');
		flashW=(typeof(flashW)=='undefined' ? 960 : flashW);
		flashH=(typeof(flashH)=='undefined' ? 120 : flashH);
		musicW=(typeof(musicW)=='undefined' ? 415 : musicW);
		musicH=(typeof(musicH)=='undefined' ? 25 : musicH);
                doClose = byId('flashclose');
		if (t==2) {
			o.style.display='';
			w = (istv ? flashW : musicW);
			h = (istv ? flashH : musicH);
			divtowrite=(istv ? 'holitv' : 'holimusic');
			var s1 = new SWFObject(file,"single",w,h,"7");
			if (typeof(s1) == 'object'){
				s1.write(divtowrite);
			}
			if (istv){
                            if (doClose){
                                (byId('flashclose')).style.display='';
                                (byId('flashopen')).style.display='none';
                                (byId('musicclose')).style.display='none';
                                (byId('musicopen')).style.display='';
                            }
			}
			else{
				(byId('holitv')).style.marginBottom='0px';
                            if (doClose){
				(byId('musicclose')).style.display='';
				(byId('musicopen')).style.display='none';
                            }
			}
		}
		else{
			o.style.display='none';
			(byId('holitv')).style.marginBottom='1px';
			(byId(divtowrite)).innerHTML=noflash;
			if (istv){
                                (byId('holimusichold')).style.display='none';
				(byId('holimusic')).innerHTML=noflash;
				if (doClose){
                                    (byId('flashclose')).style.display='none';
                                    (byId('flashopen')).style.display='';
                                    (byId('musicclose')).style.display='none';
                                    (byId('musicopen')).style.display='none';
                                }
			}else{
				(byId('holitv')).style.marginBottom='1px';
                                if (doClose){
                                    (byId('musicclose')).style.display='none';
                                    (byId('musicopen')).style.display='';
                                }
			}
		}
	}else{
		if (!dontWarn){
			msg();
		}
	}
}
function statusTxt(txt)
{
	status=txt;
	return true;
}
function goOrFreeze(url)
{
	baseUrl=resolveBLink(document.location.href);
	if (baseUrl.toLowerCase() == url.toLowerCase())
		void(0);
	else{
		if  (baseUrl.indexOf('?after') > -1 || baseUrl.indexOf('?action') > -1) {baseUrl = "";}
		document.location=url; //+(url.indexOf("?") > -1 ? "&" : "?")+'backlink='+baseUrl;
	}
}

function basename(url)
{
	arrSlash=url.split('\/');
	return (arrSlash.length ? arrSlash[arrSlash.length-1] : '');
}
function resolveBLink(url)
{
	cRet = url.replace(/\?backlink=.+[&]/,'?');
	cRet = cRet.replace(/&backlink=.+[&]/,'&');
	cRet = cRet.replace(/\?backlink=.*/,'');
	cRet = cRet.replace(/&backlink=.*/,'');
	
	return cRet;
	
}
function opToIndexOf(str,needle){return (str ? (needle ? (str.indexOf(needle) > -1 ? str.substr(0,str.indexOf(needle)) : str) : str) : '');}
function nospace(c) {return (c ? ((c.replace(/^\s+/,"")).replace(/\s+$/,"")).replace(/ {2,}/g," ") : "");}
function inRangeOfLen(str,minChr,maxChr) {return ((str.length >= minChr) && (str.length <= maxChr));}

function insertOTilde(isUpper,obj)
{
	otilde= (typeof(obj) == 'string' ? byId(obj) : obj);
	if (otilde) 
	{
		tilde = String.fromCharCode(245); tilde=(isUpper ? tilde.toUpperCase() : tilde);
		if (typeof(document.selection) != 'undefined') 
		{
			otilde.focus();
			oSel=document.selection.createRange(); setTimeout("oSel.text=tilde;", 50);
		}
		else 
		{
			if (typeof(otilde.selectionStart) != 'undefined')
			{
				if (otilde.selectionStart >= 0)
				{
					otilde.value=otilde.value.substr(0, otilde.selectionStart) + tilde + otilde.value.substr(otilde.selectionEnd);
				}
				else 
				{
					otilde.value=tilde;
				}
			}
			else
			{
				 alert('Browser Anda tidak support');
			}
		}
	}
}
var isOnkeyUp=false;
function keyUpHandler(e, nKode,cJob)
{
	if (isOnkeyUp) {isOnkeyUp=false; return;} else{
	if (e.keyCode && e.keyCode==nKode) 
		if (cJob.indexOf('(') > -1) eval(cJob); else (byId(cJob) ? ((byId(cJob)).focus ? (byId(cJob)).focus() : ((byId(cJob)).select ? (byId(cJob)).select() : void(0))) : void(0));}
	if (e.preventDefault) e.preventDefault();
}
