// Paths
var fullBaseUrl = 'http://www.thefocalpoint.com';
var workingDir  = '/'; 


/* Dropdown menu hover for IE */
sfHover = function() {	
	if($("#primary-nav").length != 0){
		var sfEls = document.getElementById("primary-nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

$(document).ready(function(){ 
	if ($("#impressions").length != 0) {
		$('#impressions').cycle({ 
			fx:     'fade', 
			timeout: 10000, 
			delay:  -2000 ,
			next: '#impression-next', 
			prev: '#impression-prev',
			pause: 1 
		});
	}
	
	if ($("#flowpanes").length != 0) {
		$("#flowpanes").scrollable({circular:true, mousewheel:true}).navigator({
			navi: "#flowtabs",
			naviItem: 'a',
			activeClass: 'current',
			history: false
		});
	}
});

$(document).ready(function() {    
	var maxHeight = 0;
	$('.column').each(function() { maxHeight = Math.max(maxHeight, $(this).height()); }).height(maxHeight);
	
	maxHeight = (maxHeight <= 600) ? 600 : maxHeight;
	$('div.column').height(maxHeight);
});

if (window.attachEvent) window.attachEvent("onload", sfHover);

function openURL(url) {
	opener.document.location = url;
	self.close();
} 

function printableImagesExhibit(exhibitId) {
	window.open(fullBaseUrl + workingDir +'cases/key-exhibits/' + exhibitId + '?print=' + 1, '_blank', 'menubar=no,scrollbars=yes,resizable=no,status=no,width=928,height=560,top=0,left=0');
}

function printableAnimationsExhibit(exhibitId) {
	window.open(fullBaseUrl + workingDir +'cases/key-exhibits/' + exhibitId + '?print=' + 1, '_blank', 'menubar=no,scrollbars=yes,resizable=no,status=no,width=982,height=608,top=0,left=0');
}

function validateUserInfo(form) {  
	if (form.username.value == "") {
		alert("Please enter a username");
		form.username.focus();
		return false;
	} else if (form.password.value == "") {
		alert("Please enter a password");
		form.password.focus();
		return false;
	} else if (form.confirm_password.value == "") {
		alert("Please re-enter your password");
		form.confirm_password.focus();
		return false;
	} else if (form.password.value != form.confirm_password.value) {
		alert("The confirmed password does not match");
		form.confirm_password.focus();	
		return false;	
	}
	
	if (form.item_id.value == "") {
		var html = $.ajax({
		type: "POST",
		url: fullBaseUrl + workingDir + "ajax/check_username.php",
		data: "username=" + form.username.value, 
		async: false
		}).responseText;
		
		if (html == "success") {
			return true;
		} else {
			alert("Username already exists");  
			return false;
		}
	}
}

function validateCaseCategoryInput(form) {  
	if (form.name.value == "") {
		alert("Please enter a name for this cateogry");
		form.name.focus();
		return false;
	} else if (form.nice_url.value == "") {
		alert("Please enter a nice url value for this cateogry");
		form.nice_url.focus();
		return false;
	} 
	
	var regexp = /[^A-Za-z0-9-]/;
	if (regexp.test(form.nice_url.value)) {
		alert("Only alphanumeric characters and '-' are allowed for nice urls");
		form.nice_url.focus();
		return false;	
	}
}

function validateEditExhibitForm(form) {  
	if (form.thumbnail.value == "") {
		alert("You must upload a thumbnail for this exhibit");
		form.thumbnail.focus();
		return false;
	}
}

function slide(slideId) {
	document.getElementById('slide').src = slides[slideId].src;
	document.getElementById('slide-btn' + slideId).style.backgroundColor = "#d4d3d2";
	currSlideId = slideId;
	
	for (i in slides) {
		if ((!isNaN(i))&&(i!=slideId)) {				
			document.getElementById('slide-btn' + i).style.backgroundColor = "#fff";
		}
	}
}



