
<!-- every page -->
$jquery(document).ready(function() {
	$jquery().ajaxStop($jquery.unblockUI);
	
	$jquery('#loginFormUI').jqm();
	
	$jquery("a[@id*=Login]").click(function(){
		showLoginForm();
   		return false;
	});
	$jquery("#ToggleContactForm").ajaxForm(function() { 
        toggleContactForm();
	}); 
    return false;
});
function toggleContactForm()	{
	if (document.getElementById("contactForm").style.display == 'none')	{
		$jquery("#contactForm").load("/gospot/ajax.ContactForm");
	}
	toggle("contactForm");
}
function loadContactForm(){
	$jquery("#ContactFormStatic").load("/gospot/ajax.ContactForm/static/true");
}
function sendContactEmail(Form){
	$jquery.ajax({
		type: "POST",
			url: "/gospot/ajax.sendContactEmail",
			data: "From=" + Form.From.value + "&Subject=" + Form.Subject.value + "&Message=" + Form.Message.value,
			success: function() {
			$jquery('#contactForm').hide('fast');
			$jquery('#contactButton').html('Your message has been sent.');
		}
	});		
	return false;
}
function sendContactEmailStatic(Form){
	$jquery.ajax({
		type: "POST",
			url: "/gospot/ajax.sendContactEmail",
			data: "From=" + Form.From.value + "&Subject=" + Form.Subject.value + "&Message=" + Form.Message.value,
			success: function() {
			$jquery('#ContactFormStatic').html('<div align=\"center\"><h2>Your message has been sent.</h2></div>');
		}
	});		
	return false;
}
function loadToolbar(){
	$jquery("#toolbar").load('/gospot/ajax.toolbar/'+Math.random());
}
function toggle(id){
	$jquery('#'+id).toggle('fast');
}
function showLoginResponse (responseText){
	if (responseText == 'true'){
            closeLoginForm();					
			reloadsecure();
			loadToolbar();		
	}
	else {
		
		$jquery("#LoginResponse").html('Oh No!  Your log in failed.');
		$jquery("#LoginResponse").show();
		$jquery("#LoginResponse").fadeOut(2000);
		document.getElementById('LoginForm').style.display = 'block';
		document.getElementById('LoginLoading').style.display = 'none';
	}
}
	
function doRegister(){
    var options = { 
    	target: "#registrationSent",
        success: showRegisterResponse  // post-submit callback 
    };  
    $jquery("#frmRegisterId").ajaxForm(options);
	$jquery("#frmRegisterId").submit(); 	
}
function showRegisterResponse(responseText){
	$jquery('#registrationSent').html(responseText);
	loadToolbar();
}
function doLogout(){
		$jquery.ajax({
		type: "POST",
				url: "/gospot/ajax.logout",
				async: false,
				success: function() {
			reloadsecure();
			$jquery("#toolbar").load('/gospot/ajax.toolbar/'+Math.random());
		}
	});
	return false;
}
function goModal(id){
	$jquery('#'+id).jqm().jqmShow();
}
function showLoginForm(){
	$jquery('#loginFormUI').load('/gospot/ajax.LoginForm/'+Math.random());
	goModal('loginFormUI');
}
function showLoginLoading(){
	document.getElementById('LoginForm').style.display = 'none';
	document.getElementById('LoginLoading').style.display = 'block';
}
function closeLoginForm(){
	var loginForm = $jquery('#loginFormUI');
	loginForm.jqm().jqmHide();
}	
function showRegistrationForm(){
	$jquery('#loginFormUI').load('/gospot/ajax.RegistrationForm/'+Math.random());
	goModal('loginFormUI');
}			
function logoutToolbar(){
	$jquery('#toolbarLogin').load('/gospot/ajax.logout/'+Math.random());
	return false;
}
function subscribeMe(){
	$jquery.post('/gospot/ajax.subscribe');
	$jquery('#subscribepod').html('You have been subscribed');
}
function subscribeUser(Form){
		$jquery.ajax({
		type: "POST",
				url: "/gospot/ajax.subscribe",
				async: false,
				data: "EmailAddress=" + Form.EmailAddress.value,
				success: function() {
			$jquery('#subscribepod').html('You have been subscribed');
		}			
			});
	return false;
}
function reloadsecure(){
	document.location.href=document.location.href;
}
function doSearch(Form){
	var content = $jquery('#content');
	if (Form.SearchTarget.value != 'Profiles'){
	content.html('<div style=\"margin-top:50px\" align=\"center\"><strong>Searching...</strong><br><img src=\"/images/loader-bar.gif" ></div>');
	$jquery('#content').load('/gospot/ajax.search/searchtarget/' + Form.SearchTarget.value + '/querystring/' + Form.queryString.value);
	}
	else {
		loadProfileSearch('content',Form.queryString.value);
	}
	return false;
}
function loadProfileSearch(id,queryString){
	if (!queryString.length){
		queryString = ' ';
	}
	$jquery('#'+id).load('/gospot/ajax.profilesearchpage/initialQueryString/'+ queryString + '/cache/'+Math.random());
	return false;
}
function doProfileSearch(callbackId,formId){
	var queryString = $jquery("#"+formId).formSerialize();
	$jquery('#'+callbackId).html('<div style=\"margin-top:50px\" align=\"center\"><strong>Searching...</strong><br><img src=\"/images/loader-bar.gif" ></div>');
		$jquery.ajax({
		type: "POST",
				url: "/gospot/ajax.profilesearch",
				async: false,
				data: queryString,
				success: function() {
					$jquery('#'+callbackId).load('/gospot/ajax.profilesearch/page/1/'+Math.random());	
				}			
			});	
	return false;
}
function loadInviteForm(id){
	
	showLoginForm();
	
}
function getSelectedValues(form,selectbox)	{
	var ValueArray = new Array();
	var SelectBox = eval("document."+form+"."+selectbox);
    for(var i=0;i<SelectBox.options.length;i++) {
        if(SelectBox.options[i].selected==true)	{
			ValueArray.push(SelectBox.options[i].value);
		}
    }
	return ValueArray;
}

/*-----------------------------------------------------------+
 | addLoadEvent: Add event handler to body when window loads |
 +-----------------------------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/*------------------------------------+
 | Functions to run when window loads |
 +------------------------------------*/
addLoadEvent(function () {
	initChecklist();
});

/*----------------------------------------------------------+
 | initChecklist: Add :hover functionality on labels for IE |
 +----------------------------------------------------------*/
function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklist") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}	
function inviteSent(id)	{
	$jquery('#'+id).html('<div style=\"padding:50px;text-align:center\" ><strong>Invitations have been sent!</strong><br /><a href=\"javascript:void(0)\" onclick=\"loadInviteForm(\'content\');\">Send More Invites</a></div>');
	
	loadToolbar();
}
function checkInvite(callbackId,Form){
	$jquery("#"+callbackId).load('/gospot/ajax.checkInvite/invitecode/'+Form.InviteCode.value);
	$jquery("#"+callbackId).fadeIn(500);
	return false;
}
function blockUI()
{
	$jquery.blockUI({ message: '<div style="padding:25px;"><h1 style="color:black">Please Wait<br><br><img src="/images/loader-bar.gif" /></h1></div>' });
}

			