/* On ready document loaded functions */
	$jq(document).ready(function(){
		$jq("#rent_form").validate();
		$jq("#myAjax-form").validate();
		
		$jq('form:last *:input[type!=hidden]:first').focus();
		$jq('#function-response-text').hide();
		//$jq('LI.drawer UL:not(:first)').hide();
		//$jq('H2.drawer-handle').click(function () {
		//	$jq('LI.drawer UL:visible').slideUp().prev().removeClass('open');
		//	$jq(this).addClass('open').next().slideDown();
		//});
		$jq('#account-signup').click(function () {
			document.location='account_signup.asp';
		});
		$jq('#account-logout').click(function () {
			document.location='logout.asp';
		});
		$jq('#account-show').click(function () {
			document.location='account.asp';
		});
		
		$jq('a.tips').cluetip({closePosition: 'title', arrows: true});
		//$jq(".shadow").dropShadow({left: 2, top: 2, opacity: 0.1, blur: 2});
		
		var options = {target:'#function-response-text',success:showResponse,clearForm: true,resetForm:true};
		$jq('#login-form').submit(function() { 
			$jq(this).ajaxSubmit(options); 
			return false; 
		}); 
		
		var MyAjaxOptions = {target:'#function-response-text',success:showMyAjaxResponse};
		$jq('#myAjax-form').submit(function() { 
			$jq(this).ajaxSubmit(MyAjaxOptions); 
			return false; 
		}); 
		
		$jq('#video-frame').cycle({
			fx:     'fade',
			speed:   1300,
			timeout: 5000,
			next:   '#video-frame',
			pause:   1
		}).show();

		
		
	});

/* Application loaded functions */
	function showRequest(formData, jqForm, options) { 
		var queryString = $jq.param(formData); 
		return true; 
	} 
	function showResponse(responseText, statusText)  { 
		var aResponseText = responseText.split(":");
		var v1=aResponseText[0]; //status
		var v2=aResponseText[1]; //värde1
		var v3=aResponseText[2]; //värde2
		var v4=aResponseText[3]; //värde2
		$jq("#function-response-text").text(v1);
		//if (v1=="SUCCESS") {$jq("#login-form-content").hide("slow");$jq('#login-form-success').show("slow");$jq('#user-name').text(v3);	$jq('#user-latest-visit').text(v4);	}
		if (v1=="SUCCESS") { document.location='index.asp';}
		else
		{ $jq('#function-response-text').show("slow"); }
	} 

	function showMyAjaxResponse(responseText, statusText)  { 
		var aResponseText = responseText.split(":");
		var v1=aResponseText[0]; //status
		var v2=aResponseText[1]; //värde1
		var v3=aResponseText[2]; //värde2
		var v4=aResponseText[3]; //värde2
		if (v1=="FUNCTION") {
			//alert('uuuuuu');
			$jq("#function-response-text").text(v3);
			if (v2=="GOBACK") { $jq("#function-response-text").text(v3); }
			$jq('#function-response-text').show("slow"); 
		}
		else if (v1=="SUCCESS") {
			$jq("#function-response-text").text(v1);
			$jq(".shadow").removeShadow();
			$jq("#form-content").hide("slow");
			$jq('#form-success').show("slow");
			$jq('#form-response-text-1').text(v3);
			$jq('#form-response-text-2').text(v4);	
			
		}
		else
		{ 
		$jq("#function-response-text").text(v1);
		//$jq("#form-content").hide("slow");
		$jq('#function-response-text').show("slow"); 
		}
	} 

/* ------------------------------------------------------------
 * POPUP WINDOW: GLOBAL VARIABLE(S)
 * ------------------------------------------------------------ */

var POPWIN  = null;

/* ------------------------------------------------------------
 * POPUP WINDOW: CLOSE EXISTING POPUP WINDOW
 * ------------------------------------------------------------ */

function closePopWin(theWin) {
  if ((theWin != null) && (theWin.closed != true))
  	theWin.close();
	}

/* ------------------------------------------------------------
 * POPUP WINDOW: DISPLAY POPUP WINDOW
 * ------------------------------------------------------------ */

function popWindow(loc,w,h) {

  //closePopWin(POPWIN);	// closes an existing popup window if user opens 
                				// new window before closing existing window
	if (!(w)) var winW = screen.width - 100; 
	else      var winW = w + 20;
	if (!(h)) var winH = screen.height - 150; 
	else      var winH = h + 20;
		
	var params  = "width=" + winW + ",height=" + winH + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50";
	POPWIN = window.open(loc,'MovieWindow',params);
	POPWIN.focus;
	}

