/*
 * 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 = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("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='url preview' />"+ 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");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});







// 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 = "#5f5f5f";
}
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 hoteluriChangePic(img)
{
	document.getElementById("thisHotelImage").src = img;
}
function locatiiChangePic(img)
{
	document.getElementById("thisLocatiiImage").src = img;
}
function showOptionals()
{
	document.getElementById("hoteluriOptionals").style.display = "block";
}
function hideOptionals()
{
	document.getElementById("hoteluriOptionals").style.display = "none";
}
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;
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
} 
