
var datescoll = new Object();
var navLi;
var lastDetail = "";        
var FilmDateArray = [];
var FilmNamesArray = [];

function goback() {
	window.history.back();
}

function showprices() {
	if (document.getElementById('prices').style.display == "block") {
		document.getElementById('prices').style.display = "none";
	} else {
		document.getElementById('prices').style.display = "block";
	}
}

function showquotes() {
	if (document.getElementById('dialog').style.display == "block") {
		document.getElementById('dialog').style.display = "none";
	} else {
		document.getElementById('dialog').style.display = "block";
		document.getElementById("dialog").style.overflow = "scroll";
		document.getElementById("dialog").style.position = "absolute";
		document.getElementById("dialog").style.height = "400px";
	}
}

function showpointer(elem) {
	document.getElementById(elem.id).style.cursor = "pointer";
}

//    function showleftmenu() {
//        document.getElementById("left-menu").style.display = "block";
//    }

function openWindow(page,winHeight,winWidth){
		window.open (page, 'newwindow', config='height=' + winHeight +', width=' + winWidth + ', toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
}

function showdetail(movie) {
	var detMovie = "detail_" + movie;
	if (lastDetail == detMovie) {
		lastDetail = "";
	}
	if (lastDetail != "") {
		document.getElementById(lastDetail).style.display = "none";
	}
	document.getElementById('dialog').innerHTML = "<a href='#' class='jqmClose'>Close</a><hr>" + document.getElementById(detMovie).innerHTML;
	document.getElementById('dialog').style.display = "block";
	if (document.getElementById(detMovie).style.display == "block") {
		document.getElementById(detMovie).style.display = "none";
	} else {
		//document.getElementById(detMovie).style.display = "block";
		lastDetail = detMovie;
	}
}

function changebgcolor(elem) {
	var idname = elem.id;
	datescoll[idname] = document.getElementById(idname).style.backgroundColor;
	document.getElementById(idname).style.backgroundColor = "black";
	document.getElementById(idname).style.cursor = "pointer";
}

function restorebgcolor(elem) {
	var idname = elem.id;
	document.getElementById(idname).style.backgroundColor = datescoll[idname];
}

function handleChangeDateEvent(e) {
	obj = new Object();
	obj.id = obj.id = e.value;
	showdate2(obj);
}

function showdate(elem) {
	var elemId;
	if (elem.id) {
		elemId = elem.id.replace("availdate", "row");
	} else {
		alert('Element has no ID');
		return;
	}
	for (d = 0; d < FilmDateArray.length; d++) {
		var dElemId = "availdate_" + FilmDateArray[d];
		if (document.getElementById(dElemId)) {
			document.getElementById(dElemId).style.backgroundColor = "#C40100";
			document.getElementById(dElemId + "_day").style.color = "white";
			document.getElementById(dElemId + "_date").style.color = "white";
			document.getElementById(dElemId + "_day").style.fontSize = '14px';
			document.getElementById(dElemId + "_date").style.fontSize = '14px';
		}
	}
	document.getElementById(elem.id).style.backgroundColor = "black";
	document.getElementById(elem.id + "_day").style.color = "white";
	document.getElementById(elem.id + "_date").style.color = "white";
	document.getElementById(elem.id + "_day").style.fontSize = '18px';
	document.getElementById(elem.id + "_date").style.fontSize = '18px';
	datescoll[elem.id] = document.getElementById(elem.id).style.backgroundColor;

	datescoll[elem.id + "_date"] = document.getElementById(elem.id + "_date").style.backgroundColor;

	for (i = 0; i < FilmNamesArray.length; i++) {
		document.getElementById(FilmNamesArray[i]).style.display = "block";
		for (y = 0; y < FilmDateArray.length; y++) {
			var hideElemId = "row_" + FilmDateArray[y] + "_" + FilmNamesArray[i];
			if (document.getElementById(hideElemId)) {
				document.getElementById(hideElemId).style.display = "none";
			}
		}
		if (document.getElementById(elemId + "_" + FilmNamesArray[i])) {
			document.getElementById(elemId + "_" + FilmNamesArray[i]).style.display = "block";
		}
		else
			document.getElementById(FilmNamesArray[i]).style.display = "none";
	}
}

function showdate2(elem) {
	var elemId;
	if (elem.id) {
		elemId = elem.id.replace("availdate", "row");
	} else {
		alert('Element has no ID');
		return;
	}

	for (i = 0; i < FilmNamesArray.length; i++) {
		document.getElementById(FilmNamesArray[i]).style.display = "block";
		for (y = 0; y < FilmDateArray.length; y++) {
			var hideElemId = "row_" + FilmDateArray[y] + "_" + FilmNamesArray[i];

			if (document.getElementById(hideElemId)) {
				document.getElementById(hideElemId).style.display = "none";
			}
		}
		if (document.getElementById(elemId + "_" + FilmNamesArray[i])) {
			document.getElementById(elemId + "_" + FilmNamesArray[i]).style.display = "block";
		}
		else
			document.getElementById(FilmNamesArray[i]).style.display = "none";
	}
}

var site = function() {
	this.navLi = $('#nav li').children('ul').hide().end();
	this.init();
};

site.prototype = {
 	
 	init : function() {
 		this.setMenu();
 	},
 	
 	// Enables the slidedown menu, and adds support for IE6
 	
 	setMenu : function() {
 	
 	$.each(this.navLi, function() {
 		if ( $(this).children('ul')[0] ) {
 			$(this)
 				.append('<span />')
 				.children('span')
 					.addClass('hasChildren')
 		}
 	});
 	
 		this.navLi.hover(function() {
 			// mouseover
			$(this).find('> ul').stop(true, true).slideDown('slow', 'easeOutBounce');
 		}, function() {
 			// mouseout
 			$(this).find('> ul').stop(true, true).hide(); 		
		});
 		
 	}
 
}

$(function() {
	// run the code in the markup!
	$('#fade').cycle({ 
	fx:    'fade', 
	speed:  4000});
	// run the code in the markup!
	$('#promo1').cycle({ 
	fx:    'fade', 
	speed:  4000 });
	// run the code in the markup!
	$('#promo2').cycle({ 
	fx:    'fade', 
	speed:  3600 });

	new site();
});

$().ready(function() {
	$('#prices').jqm();
	$('#dialog').jqm();
	
	// run doonload function if it exists
	if(typeof doonload == 'function') {
		doonload();
	}
	
	
});

