// JavaScript Document
//Preload close button Image

var flicker_delay = 300; 


//window.onerror = handleErr(msg,url,l);

function ShowListMessage(img,txt,color) 
{ 
	document.getElementById('bubblemsgbody').style.color = color; 
	document.getElementById('bubblemsgbody').innerHTML = txt; 
	if(img == '') 
	{ 
		document.getElementById('bubblemsgimage').style.display = 'none'; 
	} 
	else 
	{ 
		document.getElementById('bubblemsgimage').innerHTML = img; 
		document.getElementById('bubblemsgimage').style.display = ''; 
	} 
	showOverlayBubble(1,'msg'); 
} 

function showOverlay(show) 
{ 
	if(!show) 
	{ 
		document.getElementById('overlay').style.display = 'none';
	} 
	else 
	{ 
		if (typeof window.opera == "undefined") 
		{ 
			var height = DomUtils.getElementHeight(document.body);
			var width = DomUtils.getElementWidth(document.body);
			document.getElementById('overlay').style.height = height + 'px'; 
			document.getElementById('overlay').style.width = width + 'px'; 
			document.getElementById('overlay').style.display = 'block';
		}
	} 
} 

function showOverlayBubble(show,type) 
{ 
	showOverlay(show); 
	if(!show && !bubbleIsClosed()) 
	{ 
		document.getElementById('salesRepPopup').style.display = (type=='salesRep' ? 'inline' : 'none');
	} 
	else if(show)
	{ 
		if(document.getElementById('salesRepPopup')) 
		{ 
			document.getElementById('salesRepPopup').style.display = (type=='salesRep' ? 'inline' : 'none'); 
		}
		
		var width = DomUtils.getWindowWidth(); 
		var height = DomUtils.getWindowHeight(); 
		var scrollX = DomUtils.getWindowScrollX(); 
		var scrollY = DomUtils.getWindowScrollY(); 
		if(width==0 || height==0 || typeof window.opera!="undefined") 
		{ 
			if(typeof window.opera=="undefined" && document.documentElement.clientWidth) 
			{ 
				width = document.documentElement.clientWidth; 
				height = document.documentElement.clientHeight; 
			} 
			else 
			{ 
				width = document.body.clientWidth; 
				height = document.body.clientHeight; 
			} 
		} 
		if(scrollX==0 || scrollY==0) 
		{ 
			scrollX = document.documentElement.scrollLeft; 
			scrollY = document.documentElement.scrollTop; 
		} 
		var bwidth = 352;
		var bheight = 231;
		document.getElementById('salesRepPopup').style.top = '150px'; 
		document.getElementById('salesRepPopup').style.left = (scrollX + (width/2) - (bwidth/2)) + 'px'; 
	} 
} 
function bubbleClose() 
{ 
	showOverlayBubble(0,''); 
} 
function bubbleIsClosed() 
{ 
	return parseInt(document.getElementById('salesRepPopup').style.left)>0 ? false : true; 
}

function callSalesRep()
{
	showOverlayBubble(1,'salesRep'); 
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

