// JavaScript Document

/*==============================================================================*/
/*========	 	THIS FUNCTION DETECT JAVASCRIPT ERROR START HERE		========*/
/*==============================================================================*/
onerror	= handleErr;

//Handle error on script
function handleErr(msg,url,l){
	
	txt  = "There was an error on this page.\n\n";
	txt += "Error: " + msg + "\n";
	txt += "URL: " + url + "\n";
	txt += "Line: " + l + "\n\n";
	txt += "Click OK to continue.\n\n";
	//alert(txt);
	return true;
	
}
/*==============================================================================*/
/*========	 	THIS FUNCTION DETECT JAVASCRIPT ERROR END HERE			========*/
/*==============================================================================*/


/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR REMOVE BLANK SPACE START HERE		========*/
/*==============================================================================*/
// Remove space from text fields
function rm_trim(inputString){
	if (typeof inputString != "string") { return inputString;}

	var temp_str = '';
	temp_str = inputString.replace(/[\s]+/g,"");
	if(temp_str == '')
		return "";
	
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " "){
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " "){
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1){
	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	}
	return retValue;
}
/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR REMOVE BLANK SPACE END HERE		========*/
/*==============================================================================*/


/*==============================================================================*/
/*========	 THIS FUNCTION IS FOR DISABLE RIGHT MOUSE BUTTON START HERE	========*/
/*==============================================================================*/
/*var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false");*/
/*==============================================================================*/
/*========	 THIS FUNCTION IS FOR DISABLE RIGHT MOUSE BUTTON END HERE	========*/
/*==============================================================================*/



/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR SHOW AND HIDE DIVE START HERE		========*/
/*==============================================================================*/
function open_div(mainDiv, sourceDiv){
	if (document.getElementById(mainDiv) && document.getElementById(sourceDiv)){
		document.getElementById(mainDiv).innerHTML = document.getElementById(sourceDiv).innerHTML;
	}
}

function show_hide(showDiv, hideDiv){	
	document.getElementById(hideDiv).style.display = "none";
	document.getElementById(showDiv).style.display = "block";
}
/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR SHOW AND HIDE DIVE END HERE		========*/
/*==============================================================================*/


/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR LIMIT THE TEXT BOX START HERE		========*/
/*==============================================================================*/
function showField(strId){
	//alert(strId);
	var strId = strId;
	document.getElementById(strId).style.display = "block";
}

function hideField(strId){
	var strId = strId;
	document.getElementById(strId).style.display = "none";
}

function limitText(limitField, limitCount, limitNum){
	if (limitField.value.length > limitNum){
		limitField.value = limitField.value.substring(0, limitNum);
	}else{
		limitCount.value = limitNum - limitField.value.length;
	}
}
/*==============================================================================*/
/*========	 	THIS FUNCTION IS FOR LIMIT THE TEXT BOX END HERE		========*/
/*==============================================================================*/


/*==============================================================================*/
/*=======	 	THIS FUNCTION IS FOR HIDE THE LINK ON HREF START HERE	========*/
/*==============================================================================*/
var offsetfromedge=0;      //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array(); //array to cache dockit instances
var dkclear=new Array();   //array to cache corresponding clearinterval pointers

function dockit(el, duration){
	this.source=document.all? document.all[el] : document.getElementById(el);
	this.source.height=this.source.offsetHeight;
	this.docheight=truebody().clientHeight;
	this.duration=duration;
	this.pagetop=0;
	this.elementoffset=this.getOffsetY();
	dockarray[dockarray.length]=this;
	var pointer=eval(dockarray.length-1);
	var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
	dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
	eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
	var totaloffset=parseInt(this.source.offsetTop);
	var parentEl=this.source.offsetParent;
	while (parentEl!=null){
		totaloffset+=parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function dockornot(obj){
	obj.pagetop=truebody().scrollTop;
	if (obj.pagetop>obj.elementoffset) //detect upper offset
		obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
	else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
		obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
	else
		obj.source.style.top=0;
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidestatus(){
	window.status='theBC.com';
	return true;
}

if (document.layers)
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK)

document.onmouseover=hidestatus
document.onmouseout=hidestatus

window.onmousedown= hidestatus
window.onmouseup= hidestatus

window.onclick= hidestatus
/*==============================================================================*/
/*=======	 	THIS FUNCTION IS FOR HIDE THE LINK ON HREF END HERE	========*/
/*==============================================================================*/

function isEmail(str){
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var ldot=str.indexOf(dot);
	var lstr=str.length;

	if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false;
	}
	if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}
	if(str.indexOf(" ")!=-1){
		return false;
	}
	if(str.indexOf(at,(lat+1))!=-1){
		return false;
	}
	if(str.indexOf(dot,(lat+2))==-1){
		return false;
	}
	if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	}
	return true;
}

/*$strTxt		= '';	
	$pattern 	= "/[^A-Z]/";	
	$ret	 	= preg_match($pattern, $theTxt, $match);
	if($ret == 0){
		$theTxt		= ucfirst(strtolower($theTxt));	
	}	
	
	$strLength 	= strlen($theTxt);
	
	for($i=0; $i<$strLength; ){
		
		$strTxt .= substr($theTxt, $i, $newLine);
		$strTxt .= "\n";
			
		$i 		 = $i + $newLine;	
	}
	$strTxt		= nl2br($strTxt);	
	return $strTxt;*/

function createNewText(theTxt, newLine){
	
	var strTxt 	= '';
	var pattern	= "/[^A-Z]/"; 
	var ret		= theTxt.match(pattern);
	
	if(ret == 0){
		theTxt 	= toLowerCase(theTxt); 
	}
	strLength 	= theTxt.length;	
	
	for(i=0; i<strLength; ){
		
		strTxt 	+= theTxt.substr(i, newLine);
		strTxt  += "<br>";
		
		i		= i + parseInt(newLine);

	}
	//alert(strTxt);return false;
	return strTxt;	
}