var pPointer, pNormal;
var m_x, m_y;
//pPointer = document.all.style;
pPointer = document.style;
pPointer = 'pointer';
pNormal = document.style;
pNormal = 'normal';

function highlightCell(cell, cursor, background, foreground)
{
	if (cursor.length)
		cell.style.cursor = pPointer;
	if (background.length)
		cell.style.background = background;
	if (foreground.length)
		cell.style.color = foreground;
}

function mouseClick(e) {
	if (!e)
		e = window.event;
	m_x = e.clientX;
	m_y = e.clientY;
	
	blurWindows();
}

document.onmousedown = mouseClick;

function changeClassNavi(cell, cursor, newClass)
{
	if (cursor.length) {
		cell.style.cursor = pPointer;
		cell.background = image_nav_over.src;
	} else {
		cell.background = image_nav_norm.src;
	}
	cell.className = newClass;
}

function changeClass(cell, cursor, newClass)
{
	if (cursor.length)
		cell.style.cursor = pPointer;
	if (newClass.length)
		cell.className = newClass;
}

function changeLocation(rel_url, new_window)
{
	if (new_window)
		w1 = window.open(rel_url, "", "");
	else
		window.location.href = rel_url;
}


function openLocation(rel_url, name, options, new_window)
{
	w1 = window.open(rel_url, name, options);
	w1.focus();
}

function ShowOnlineHelp()
{
	olh = window.open('/lexikon.php', 'online_help', 'left=25,top=25,width=550,height=400'); 
	olh.focus();
}

function ClearList(form, source)
{
	while (document[form][source].length > 0)
		document[form][source].remove(0);
}

function CopyList(form, source, destination)
{
	ClearList(form, destination);
	
	for (i = 0; i < document[form][source].length; i++) {
		item_new = new Option(document[form][source].options[i].text, document[form][source].options[i].value);
		document[form][destination].options[i] = item_new;
	}
	
	document[form][destination].disabled 		= document[form][source].disabled;
	document[form][destination].selectedIndex	= document[form][source].selectedIndex;
}

function ShowConditionsOnCar(car_id)
{
	window_cardetails = window.open("konditionen.php?car_id=" + car_id + "&session=" + results.session_id.value, "car_details_" + car_id.replace(/,/, "_"), "left=25,top=25,width=640,height=480,scrollbars=yes");
	window_cardetails.focus();
}

function ShowConditionsOnCarFromBooking(car_id, session_id)
{
	window_cardetails = window.open("konditionen.php?car_id=" + car_id + "&session=" + session_id, "car_details_" + car_id.replace(/,/, "_"), "left=25,top=25,width=640,height=480,scrollbars=yes");
	window_cardetails.focus();
}

function addFavorites() 
{
	var url = "../";
	var title = "IhrMietwagen.de - Mietwagenpreisvergleich";
	
	if (document.all && !window.opera) { // IE5+
		window.external.AddFavorite(url, title)
	} else
	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
		window.sidebar.addPanel(title, url, "")
	} else {
		alert("Ihr Browser unterstützt diese Funktion leider nicht!"); 
	}
}

function showDIVLayer(_id, _status) {
	document.getElementById(_id).style.visibility = ((_status == true) ? 'visible' : 'hidden');
}

function blurWindows() {
	var calendar = document.getElementById("calendar");
	if (calendar)
	{
		if (calendar.style.visibility != 'hidden')
		{
			var cx = parseInt(calendar.style.left)  - document.body.scrollLeft;
			var cy = parseInt(calendar.style.top)   - document.body.scrollTop;
			var cw = parseInt(calendar.style.width) ;
			var ch = parseInt(calendar.style.height);
			
			if ((m_x < cx || m_x > (cx + cw) || m_y < cy || m_y > (cy + ch)))
			{
				document.getElementById("calendar").style.visibility = 'hidden';
				document.getElementById("ie_if_ca").style.visibility = 'hidden';
			}
		}
	}
}
