/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
this.screenshotPreview = function(){	
	/* CONFIG */
	xOffset = 10;
	yOffset = 20;		
	/* END CONFIG */
	if($("a.screenshot"))
	{
		$("a.screenshot").hover(function(e){
			this.t = this.title;
			this.title = "";	
			var c = (this.t != "") ? "<br/>" + this.t : "";
			$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='' />"+ c +"</p>");								 
			$("#screenshot")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");						
		},
		function(){
			this.title = this.t;	
			$("#screenshot").remove();
		});	
		$("a.screenshot").mousemove(function(e){
			$("#screenshot")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});		
	}	
};
$(document).ready(function(){
	screenshotPreview();
});

function openNewWindow(URLtoOpen, windowName) {
	var ScreenTop = (screen.height/2)-250;
	var ScreeLeft = (screen.width/2)-262;
	newWindow=window.open(URLtoOpen, windowName, "width=524, height=524, top="+ScreenTop+", left="+ScreeLeft+", toolbar=0, scrollbars=1, resizable=0, location=0, status=0");
}

// menu left
function mOver(id)
{
	document.getElementById(id).style.background = "url("+SITE_ROOT+"static/image/menu_left_bg_hover.jpg)";
	document.getElementById(id).style.color = "#ffffff";
}
function mOut(id, noHr)
{
	if(noHr==true)
	{
		document.getElementById(id).style.background = "url("+SITE_ROOT+"static/image/menu_left_bg.jpg)";
		document.getElementById(id).style.backgroundRepeat = "no-repeat";
		document.getElementById(id).style.backgroundPosition = "bottom";
	}
	else
	{
		document.getElementById(id).style.background = "url("+SITE_ROOT+"static/image/spacer.gif)";
	}
	document.getElementById(id).style.color = "#cccccc";
}
function mOverS(id)
{
	document.getElementById(id).style.color = "#008af4";
}
function mOutS(id)
{
	document.getElementById(id).style.color = "#333333";
}
// end menu left
function multimediaMOver(id)
{
	document.getElementById(id).style.background = "url("+SITE_ROOT+"static/image/bg_multimedia.jpg)";
	document.getElementById(id).style.backgroundRepeat = "no-repeat";
}
function multimediaMOut(id)
{
	document.getElementById(id).style.background = "url("+SITE_ROOT+"static/image/spacer.gif)";
}
// start multimedia

// end multimedia
function changeCarPreviewColor(elementId, img, colorName)
{
	document.getElementById(elementId).src = img;
	document.getElementById("colorTitle").innerHTML = colorName;
}
function changePic(img)
{
	document.getElementById("thisImage").src = img;
}

function formatCurrency(amount, noDecimals)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(noDecimals!=1){
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	}
	s = minus + s;
	return s;
}