	var ai_account_id = '';
	var ai_name_1 = '';
	var ai_street_address_1 = '';
	var ai_city = '';
	var ai_state = '';
	var ai_zip = '';
	var ai_ppl = '';
	var acctInfoHTML = '';
	
$(document).ready(function() {
	//$('#lastLogin').show();
	//pingLogin();
	$("#features").cycle({
		fx: 'scrollHorz',
		timeout: 5000,
		//random: 1,
		prev:    '#featPrev',
        next:    '#featNext'
	});

	$("ul.sf-menu").superfish(); 

	getTwitters('wvaTwitter', {
		id: 'wisvis', 
		template: '<span class="twitterPrefix"><span class="twitterStatus">%text%</span> <em class="twitterTime"><a href="http://twitter.com/%user_screen_name%/statuses/%id%">%time%</a></em>',       
		clearContents: true, // leave the original message in place
		count: 4, 
		withFriends: true,
		ignoreReplies: false,
		newwindow: true
	});

	$(".stripeMe tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	$(".stripeMe tr:even").addClass("alt");
	$(".stripeMe td:even").addClass("align");

$(function() {
		$(".flexibleAccordion").accordion({
			autoHeight: false,
			navigation: true,
			active: false,
			collapsible: true
		});
	});
	

$("a.fancybox").fancybox();


$("#report tr:odd").addClass("odd");
            $("#report tr:not(.odd)").hide();
            $("#report tr:first-child").show();
            
            $("#report tr.odd").click(function(){
                $(this).next("tr").toggle();
                $(this).find(".arrow").toggleClass("up");
            });

	$('.trigger a').before("<div class='arrow'></div>");			


$(".toggle").hide(); 
	$(".trigger").click(function(){
	$(this).toggleClass("active").next().slideToggle("slow");
    $(this).find(".arrow").toggleClass("up");	
	});
	
autoLoginWVA();	

});		// END Doc Ready
function isEmpty(text) {
	if( text.length == 0 || isBlank(text) ) {
		return true;
	}
	return false;
}
function isBlank(text) {
	for( i=0; i < text.length; i++ ) {	
		if( text[i] != " " ) {
			return false;
		}
	}
	return true;
}
function getURLQuery(parameter){
	parameter = parameter.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  	var regexS = "[\\?&]"+parameter+"=([^&#]*)";
  	var regex = new RegExp( regexS );
  	var results = regex.exec( window.location.href );
  	if( results == null )
    	return "";
  	else
    	return results[1];
}

function pingLogin() {
	$.ajax({
		url: "https://www.wewillship.com/php/accountCheck.php",
		cache: false,
		type:"POST",
		dataType:"xml",
		success: function(logindata){
			if($("validation",logindata).text() == "valid"){
				acctInfo_WP();
				$('#lastLogin').hide();
				$('#lastLogout').show();
			}else{
				$('#lastLogin').show();
				$('#lastLogout').hide();
			}
		}
	}); //end .ajax call
}
function acctInfo_WP(){
//	alert('running acct info')
	$.ajax({
		url: "https://www.wewillship.com/php/acctInfo.php?",
		cache: false,
		type:"GET",
		dataType:"xml",
		success: function(xml){
			$(xml).find('acctinfo').each(function(){
				ai_account_id = $(this).find('account_id').text();
				ai_name_1 = $(this).find('name_1').text();
				ai_street_address_1 = $(this).find('street_address_1').text();
				ai_city = $(this).find('city').text();
				ai_state = $(this).find('state').text();
				ai_zip = $(this).find('zip').text();
				ai_ppl = $(this).find('patient_price_like').text();
				acctInfoHTML = "<p>" + "You are logged in as" + "&nbsp;" + "<span>" + ai_name_1 + " | " + ai_street_address_1 + "&nbsp;" + ai_city + ", " + ai_state + "&nbsp;" + ai_zip + "</span>" + "</p>";
			   	$('#stoAcctInfo').html(acctInfoHTML);
				$('#stpAcctInfo').html(acctInfoHTML);
			});
		}
	});
}
function logout() {
	$.ajax({
		url: "https://www.wewillship.com/php/deleteSessionVariables.php",
		cache: false,
		type:"POST",
		dataType:"xml",
		success: function(data){
			window.location="http://www.wisvis.com";
		}
	});
}
function autoLoginWVA() {
	var id=getURLQuery("id");
	var code=getURLQuery("code");
	var navTo=getURLQuery("nav");

//	alert('in auto login WVA')
//	alert('id = '+id);
//	alert('code = '+code);
	if((!isEmpty(id))&&(!isEmpty(code))){
		$.ajax({
//			url: "https://www.wewillship.com/php/validateLogin.php",
			url: "https://www.wewillship.com/php/validateLogin.php",
			data:"username="+encodeURI(id) + "&password="+encodeURI(code),
			cache: false,
			type:"POST",
			dataType:"xml",
			success: function(data){
				if($("login_status",data).text() == "invalid"){
					//login errors
					if($("error",data).text() == "Computer is already logged in"){
						alert("This computer is already logged into the system\nPlease close all internet browsers and try again");	
					}else if($("error",data).text() == "Invalid Username"){	
						alert("Invalid Username");
					}else if($("error",data).text() == "Invalid Password"){
						alert("Invalid Password");
					}
				}else{
					$.ajax({
//						url: "https://www.wewillship.com/php/loginUser.php",
						url: "https://www.wewillship.com/php/loginUser.php",
						data:"user_id="+encodeURI(id),	// + "&password="+encodeURI(code)
						cache: false,
						type:"POST",
						dataType:"xml",
						success: function(data){
							if($("login_status",data).text() == "invalid"){
								//login errors
								if($("error",data).text() == "Computer is already logged in"){
									alert("This computer is already logged into the system\nPlease close all internet browsers and try again");	
								}else if($("error",data).text() == "Invalid Username"){	
									alert("Invalid Username");
								}else if($("error",data).text() == "Invalid Password"){
									alert("Invalid Password");
								}
//							}else{
//								$('#welcome').html('Welcome');
							}
						}
					}); //end .ajax call
				}
				if(navTo!=''){
					custnavTo = "https://www.wewillship.com/landing.html?navTo="+navTo;
					location.href=custnavTo;
				}
				
			}
		}); //end .ajax call
	}
}




