
//set the mouseover and mouseout events to imagaes with class "change_img"
function setEventsToImages() {
	var x = document.getElementsByTagName('img');
	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'change_img') {
			x[i].onmouseover = switch_src;
			x[i].onmouseout = switch_src;
		} else if (x[i].className == 'star_dvdrating') {
			x[i].onmouseover = simulateRating;
			x[i].onmouseout = simulateRating;
			var ss = x[i].id.split("_");
			x[i].setAttribute("dvdid", ss[1]);
			x[i].setAttribute("userid", 15490);
			x[i].setAttribute("rating", ss[2]*3);
			x[i].onclick = saveRating;
		}
	}

	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'change_img') {
			x[i].onmouseover = switch_src;
			x[i].onmouseout = switch_src;
		}
	}


}

//get the element attached to the specified event
function getEventElement(e) {
	if (!e) var e = window.event;
	el = (e.target) ? e.target : e.srcElement;
	return el;
}

//get the type of the specified event
function getEventType(e) {
	if (!e) var e = window.event;
	return e.type;
}

//set mouse cursor to default of to hourglass
//e - event
function setMouseCursor(e) {
	if (!e) var e = window.event;
	el = (e.target) ? e.target : e.srcElement;
	//alert("e=" + e.type);
	if (e.type == "mouseover")
		el.style.cursor = 'pointer';
	else if (e.type == "mouseout")
		el.style.cursor = 'default';
}

//function used at mouseover and mouse out
//change the image of the element attached to specified event
//the mouse over images should have _over in name
function switch_src(e) {
	el = getEventElement(e);
	if (el.getAttribute("changeImg") && (el.getAttribute("changeImg") == "true")) {
		return;
	} else if (el.getAttribute("changeImg") && (el.getAttribute("changeImg") == "out")) {
		el.setAttribute("changeImg", "false");
		return;
	} else {
		var e_type = getEventType(e);
		el_src = el.src;
		if (e_type == "mouseover")
			el_src = el_src.replace(".gif", "_over.gif");
		else if (e_type == "mouseout")
			el_src = el_src.replace("_over.gif", ".gif");
		el.src = el_src;
	}
}

//select the specified option from second menu
//the id of the image that must be selected should be "sm_" + p_secondMenu
function selectSecondMenu(p_secondMenu) {
	var currimg = document.getElementById("sm_" + p_secondMenu);
	if (currimg) {
		currimg.src = currimg.src.replace(".gif", "_high.gif");
		currimg.setAttribute("changeImg", "true");
	}
}

function selectThirdMenu(p_thirdMenu) {
	var currimg = document.getElementById("tm_" + p_thirdMenu);
	if (currimg) {
		currimg.src = currimg.src.replace(".gif", "_over.gif");
		currimg.setAttribute("changeImg", "true");
	}
}


//history back
function back() {
	history.back();
	return false;
}

function doAdvSearch() {
    document.adv_search.submit();
}
