
function trim(s) 
{
	return s.replace(/^\s+|\s+$/g,'');
}

var ieHover = function() {
	var ele = document.getElementById("nav-ul").getElementsByTagName("li");
	for (i=0; i<ele.length; i++) {

		ele[i].onmouseover=function() {
			this.className = "iehover bghover";
		}
		ele[i].onmouseout=function() {
			this.className = this.className.replace("iehover", "");
			this.className = this.className.replace("bghover", "");
		}
	}

	var ele = document.getElementById("client-list-box");
	ele.onmouseover=function() {
		this.className = "hover";
	}
	ele.onmouseout=function() {
		this.className = this.className.replace("hover", "");
	}		
}

function show_invoice(obj)
{
	var url = obj.href;
	window.open(url, 'invoice', 'width=900,height=700,resizable=yes,scrollbars=yes');
	return false;
}

function hover_this(obj)
{
	var src = obj.src;
	var state = src.match(/^.*?-(off|on).([\w\d]{2,4})$/);
	var flip = state[1] == 'off' ? 'on' : 'off';
	
	obj.src = src.replace(state[1]+'.'+state[2], flip+'.'+state[2]);
}
/*
function hover_this(obj)
{
	var state = "";
	var lnk = document.getElementById('marketing-bottom').getElementsByTagName('img');
	for (var i=0; i < lnk.length; i++)
	{
		if (lnk[i] != obj) {
			state = lnk[i].src.match(/^.*?-(off|on).([\w\d]{2,4})$/);
			lnk[i].src = lnk[i].src.replace(state[1]+'.'+state[2], 'off.'+state[2]);
		}
	}
	var src = obj.src;
	state = src.match(/^.*?-(off|on).([\w\d]{2,4})$/);
	var flip = state[1] == 'off' ? 'on' : 'off';
	
	obj.src = src.replace(state[1]+'.'+state[2], flip+'.'+state[2]);
}
*/
function add_event(type, fn)
{
    if (window.addEventListener){
        window.addEventListener(type, fn, '');
    } else if (window.attachEvent){
        window.attachEvent('on' + type, fn);
    }
}

function marketing_hover(loc, state)
{
	if (state) {
		if (loc == 'left') {
			document.getElementById('hover-img').src = hover_left.src;	
		} else if (loc == 'mid') {
			document.getElementById('hover-img').src = hover_mid.src;	
		} else {
			document.getElementById('hover-img').src = hover_right.src;	
		}
	} else {
		document.getElementById('hover-img').src = hover_off.src;	
	}
}

function request_info(loc)
{
	window.location = http + '/about-mobiltape/request-more/' + loc;	
}

add_event("load", ieHover, ''); 

function marketing_product(obj)
{
	ajaxReq.open("GET", http+ "/marketing-product.php?prod=" + obj.name + "&check=" + (obj.checked ? 1 : 0), true);
	ajaxReq.onreadystatechange = function() {
		if(ajaxReq.readyState == 4){
		}
	}
	ajaxReq.send(null); 		
}