$(document).ready(function(){
	//camel-weight
	$('.camel-weight').each(function(i) {
		var strVal=String($(this).html());
		var strValNew='';
		var tmpChar='';
		for(var c=0;c<strVal.length;c++){
			if(strVal.substr(c,5)=='&amp;'){
				strValNew+=strVal.substr(c,5);
				c+=4;
			}else{
				tmpChar=strVal.substr(c,1)
				if(Math.random()>0.5){
					strValNew+='<span class="camel-weight-alt">'+tmpChar+'</span>';
				}else{
					strValNew+=tmpChar;
				}
			}
		}
		$(this).html(strValNew)
	});
	//clear on click form fields
	$('.clear-on-click').each(function(i){
		if($(this).val()==''){
			$(this).val($(this).attr('title'));
		}
	});
	$('.clear-on-click').click(function(){
		if($(this).val()==$(this).attr('title')){
			$(this).val('');
		}
		var prevFieldset=$(this).parent().prev();
		if(prevFieldset.hasClass('error')){
			prevFieldset.children('span').hide();
			prevFieldset.slideUp('fast');
		}
	});
	$('.clear-on-click').blur(function(){
		if($(this).val()==''){
			$(this).val($(this).attr('title'));
		}
	});
	//confirm link
	$(".confirmlink").click(function(e){
		var msg=$(this).attr("title");
		if(msg==''){
			msg=confirmActionMessage;
		}
		var url=$(this).attr("href");
		var confirmDelete=confirm(msg);
		if(confirmDelete==true){
			window.location=url;
		}
		return false;
	});
	//hide success messages
	//setTimeout('hideElementTimer()',2000)
	$('body').click(function(){
		$(".message-success").slideUp('slow');
	});
	
	$(".play-stash-video").click(function(){
		$("#stash-video-overlay").show()
		return false;
	});
	$("#stash-video-overlay #stash-video-overlay-content .hide").click(function(){
		$("#stash-video-overlay").hide()
		return false;
	});
});

//form cancel function
function cancelFormSubmit(loc) {
	window.location=loc;
}
//hide elements on click anywhere
function hideElementInteraction() {
	$(".message-success").slideUp('slow');
}
//hide elements on timer
function hideElementTimer() {
	
}

function detectBrowser(){
	var userAgent = navigator.userAgent.toLowerCase();
	$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
	var version = 0;
	var browserName ='';
	
	// Is this a version of IE?
	if($.browser.msie){
		userAgent = $.browser.version;
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browserName='IE';
	}
	
	// Is this a version of Chrome?
	if($.browser.chrome){
		userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		// If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
		$.browser.safari = false;
		browserName='Chrome';
	}
	
	// Is this a version of Safari?
	if($.browser.safari){
		userAgent = userAgent.substring(userAgent.indexOf('safari/') +7);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browserName='Safari';
	}
	
	// Is this a version of Mozilla?
	if($.browser.mozilla){
		//Is it Firefox?
		if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){
			userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
			userAgent = userAgent.substring(0,userAgent.indexOf('.'));
			version = userAgent;
			browserName='Firefox';
		}
		// If not then it must be another Mozilla
		else{
		}
	}
	
	// Is this a version of Opera?
	if($.browser.opera){
		userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browserName='Opera';
	}
	return browserName+' '+version;
}
