//*********************************************************************************************

function setc(IDSET, CSET) {

	if (IDSET == 'n') { return; }
	if (document.getElementById) {
		document.getElementById(IDSET).className = CSET;
	} else if (document.all) {
		document.all[IDSET].className = CSET;
	} else if (document.layers) {
		document.layers[IDSET].className = CSET;
	}
}

//*********************************************************************************************

function ccAll(formName, state) {

    if (document.getElementById) {
        var boxes = document.getElementById(formName).getElementsByTagName('input');
    } else {
        return;
    }

    (state == true) ? color = '#E1EAEC':color = '#eff7ff';

    for (var i = 0; i < boxes.length; i++) {
        if (boxes[i].type == 'checkbox' && boxes[i].id != "checkall" && boxes[i].disabled == false){
            boxes[i].checked = state;
            document.getElementById('r_'+ boxes[i].id).style.background = color;
        }
    }
}

//*********************************************************************************************

function highlight(box, obj)
{
    if (!document.getElementById) {
        return;
    }
	var color1 = '#E1EAEC'
    var color2 = '#eff7ff';
    document.getElementById(obj).style.background = (box.checked ? color1 : color2);
}

//*********************************************************************************************

function m_search() {
	shl('footer', 'h');
	shl('bg_container', 'h');
	shl('search', 's');
}

function m_submit(a) {
	
	document.form.submit.disabled = true; 
	document.form.submit.value = 'Please Wait..';
	
	if (a == 's') {
		if (!document.getElementById) {
			return;
		}
		
		shl('bground', 's');
		shl('loader', 's');
		
		document.getElementById('loader').style.top = getCentre('top') + 'px';
		document.getElementById('loader').style.left = getCentre('left') + 'px';
		
		document.getElementById('bground').style.height = getCentre('scr_height') + 'px';
		document.getElementById('bground').style.width = getCentre('scr_width') + 'px';
	}
}

//*********************************************************************************************

function shl(a, b) {
	if (!document.getElementById) {
        return;
    }
	if (b == 'h') {
		document.getElementById(a).style.display = 'none';
	} else if (b == 's') {
		document.getElementById(a).style.display = 'block';
	}
}

//*********************************************************************************************

function popUpWindow(URLStr, left, top, width, height)
{
  var popUpWin=0;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

//*********************************************************************************************

function SetAction(FormName, IN, RES, MESS) {
	document.forms[FormName].action.value = IN;
	var ron = RES;
	if (ron == 'warn') {
	response = confirm(MESS);
		if (response) {
			document.bgColor = 12632256;
			document.forms[FormName].submit();
			return true;
		} else { 
			return false; 
		}
	} else { 
		response = 0; 
	}		
	document.forms[FormName].submit();
}

//*********************************************************************************************

function toggleOther(chosen) {
	
// decide whether to show 'other' field
if (document.theForm.hear_about) {
	var billother = new getObj('billing_other');
	var billspecify = new getObj('billing_specify');
	if (billother.obj) {
		if (chosen == 'Other' || chosen == 'Other Search Engine') {
			billspecify.style.display = "";
		} else {
			billspecify.style.display = "none";
		}
	}
}

// decide whether to show billing screen
if (chosen == 'base') {
	if (document.theForm.billing_check) {
		for (i=0; i<7; i++) {
			if (document.theForm.billing_check.checked) {
				document.getElementById("billingTR_" + i).style.display = "none";
			} else {
				document.getElementById("billingTR_" + i).style.display = "";
			}
		}
	}
}

}

//*********************************************************************************************

function doSomething(e)
{
	var posx = 0;
	var posy = 0;

	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		//posx = e.clientX + document.body.scrollLeft;
		//posy = e.clientY + document.body.scrollTop;
		posx = e.clientX + document.documentElement.scrollLeft || document.body.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop || document.body.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	x0lr.style.left = posx + offX + 'px';
	x0lr.style.top = posy + offY + 'px';
}

//*********************************************************************************************

function ShowHelp(element, title, desc, fl, ft) 
{
	if(!fl) fl = 15;
	if(!ft) ft = -5;
	offX = fl;
	offY = ft;
	x0lr = new getObj('' + element + '');
	document.onclick = doSomething;
	var content = '<span class="showhelp"><strong>' + title + '</strong><br>' + desc + '<br /></span>';
	
	x0lr.style.display = 'inline';
	x0lr.style.position = 'absolute';
	x0lr.style.width = '200px';
	x0lr.style.backgroundColor = 'lightyellow';
	x0lr.style.border = 'dashed 1px black';
	x0lr.style.padding = '7px';
	x0lr.obj.innerHTML = content;
}

//*********************************************************************************************

function HideHelp(element) {
	var x02r = new getObj('' + element + '');
	x02r.style.display = 'none';
}

//*********************************************************************************************
// toggle form element only

function toggleDD(element, type) {
	if (document.theForm[element]) {
		var ele = new getObj(element);
		if (ele) {
			ele.style.visibility = '' + type + '' ;
		}
	}
}	

//*********************************************************************************************

function getObj(name) {
	if (document.getElementById) {
  		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  	}
  	else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  	}
  	else if (document.layers) {
   		this.obj = document.layers[name];
   		this.style = document.layers[name];
  	}
}

//*********************************************************************************************

function toggleCells(id) {
	var x0 = new getObj('newuser_0');
	var x1 = new getObj('newuser_1');
	var x2 = new getObj('newuser_2');
	
	if (document.theForm.new_user[0] && document.theForm.new_user[1]) {
		if (document.theForm.new_user[1].checked) {
			x0.style.display = "none";
			x1.style.display = "none";
			x2.style.display = "none";
		} else {
			x0.style.display = "";
			x1.style.display = "";
			x2.style.display = "";
		}
	}
}

//*********************************************************************************************

function getCentre(target) {
	var innerSH, innerSW, offsetL, offsetT, scrollW, scrollH;
	// get the innerwidths
	if (self.innerHeight) { // all except Explorer
		innerSW = self.innerWidth;
		innerSH = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		innerSW = document.documentElement.clientWidth;
		innerSH = document.documentElement.clientHeight;
	} 
	else if (document.body) { // other Explorers
		innerSW = document.body.clientWidth;
		innerSH = document.body.clientHeight;
	}

	// get the scroll offset
	if (self.pageYOffset) { // all except Explorer
		offsetL = self.pageXOffset;
		offsetT = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
		offsetL = document.documentElement.scrollLeft;
		offsetT = document.documentElement.scrollTop;
	}
	else if (document.body) { // all other Explorers
		offsetL = document.body.scrollLeft;
		offsetT = document.body.scrollTop;
	}
	
	// get the full scrolled height and widths
	var ck1 = document.body.scrollHeight;
	var ck2 = document.body.offsetHeight
	if (ck1 > ck2) { // all but Explorer Mac
		scrollW = document.body.scrollWidth;
		scrollH = document.body.scrollHeight;
	}
	else { // Explorer Mac, would also work in Explorer 6 Strict, Mozilla and Safari
		scrollW = document.body.offsetWidth;
		scrollH = document.body.offsetHeight;
	}
	
	var innerSH_half = eval(innerSH / 2);
	var innerSW_half = eval(innerSW / 2);
	var realLeft = eval((innerSW_half + offsetL) - 160);
	var realTop = eval((innerSH_half + offsetT) - 50);
	
	if (target=='top') {
		return realTop;
	} 
	else if (target=='left') {
		return realLeft;
	}
	else if (target=='scr_height') {
		return scrollH;
	}
	else if (target=='scr_width') {
		return innerSW;
	}
}

//*********************************************************************************************

function layers(act, t, b) {
	if (document.layers) {
		return false;
	}
	var innerSH, innerSW, offsetL, offsetT, scrollW, scrollH;
	var x0 = new getObj('loader');
	var x1 = new getObj('bground');
	var x2 = new getObj('ifr');
	
	if (document.getElementById) {
		var select_arr = document.getElementsByTagName("select");
	}
	else if (document.all) {
		var select_arr = document.all.tags("select");
	}
	
	if (x0!=null) {
		if (t=='y') {
			x0.style.top = getCentre('top') + 'px';
			x0.style.left = getCentre('left') + 'px';
			//x0.style.left = '285px';
			x0.style.visibility = (act=='on')?'visible':'hidden';
			x0.style.display = (act=='on')?'block':'none';
			x0.style.zIndex = 3;
		}
		if (b=='y') {
			x1.style.height = getCentre('scr_height') + 'px';
			x1.style.width = getCentre('scr_width') + 'px';
			x1.style.visibility = (act=='on')?'visible':'hidden';
			x1.style.display = (act=='on')?'block':'none';
			x1.style.zIndex = 2;
			
			x2.style.height = getCentre('scr_height') + 'px';
			x2.style.width = getCentre('scr_width') + 'px';
			x2.style.visibility = (act=='on')?'visible':'hidden';
			x2.style.display = (act=='on')?'block':'none';
			// x2.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			x2.style.zIndex = 1;
		}
		/*
		for (var i = 0; i < select_arr.length; i++) {
			select_arr[i].style.visibility = (act=='on') ? 'hidden':'visible';
			//select_arr[i].style.display = 'none';
		}
		for (var i = 0; i < select_arr.length; i++) {
			select_arr[i].style.visibility = (act=='off') ? 'visible':'hidden';
			//select_arr[i].style.display = 'none';
		} 
		*/
	}
}

//*********************************************************************************************

function selects(val) {
	if (document.layers) {
		return false;
	}
	if (document.getElementById) {
		var select_arr = document.getElementsByTagName("select");
	}
	else if (document.all) {
		var select_arr = document.all.tags("select");
	}
	for (var i = 0; i < select_arr.length; i++) {
		select_arr[i].style.visibility = (val == 'off') ? 'hidden':'visible';
	}
}

//*********************************************************************************************

function selectsDis(val) {
	if (document.layers) {
		return false;
	}
	if (document.getElementById) {
		var select_arr = document.getElementsByTagName("select");
	}
	else if (document.all) {
		var select_arr = document.all.tags("select");
	}
	for (var i = 0; i < select_arr.length; i++) {
		select_arr[i].disabled = (val == 'off') ? true:false;
	}
}

//*********************************************************************************************
