  var qStr;
function queryField(opt)
{
 var keyloc
 var nextkey
 var start 
 var opts
 var optval
 opts=location.search
 keyloc = opts.indexOf("&" + opt + "=")
 if(keyloc == -1) {
 keyloc = opts.indexOf("?" + opt + "=")
 }
 if (keyloc == -1) {
 return ""
 } 
 nextkey = opts.indexOf("&",keyloc+1) 
 // But sometimes there is no next pair
 if (nextkey == -1) {
 nextkey = opts.length
 }
 // Okay, what next? Verify that it's reasonable
 if (nextkey < keyloc) {
 return ""
 } 
 // Get and return the value
 sval = keyloc+2+opt.length;
optval = ptospace(unescape(opts.substring(sval,nextkey)))
 return optval
} // getOption()

function ptospace(txt)
{
 // Sanity check on empty string
 if (txt == "") { return txt }
 
 // Variables
 var newtxt=""; // The txt without the spaces
 var pos=0; // The position of the plus sign
 var prev=0; 
 var done=false; // sentinel for loop
 var tmp; // Used for debugging
 while (!done) {
 pos = txt.indexOf("+",prev)
 if (prev >= txt.length) {
 done = true
 }
 else if (pos == 0) {
 prev=1
 newtxt += " "
 }
 else if ((pos < 0) || (pos == "")) {
 // Not found ... exit
 done = true
 }
 else {
 // Copy text
 if (pos>prev) { newtxt += txt.substring(prev,pos) }
 newtxt += " "
 // And move on
 prev=pos+1
 }
 }
 // Get the last little bit
 newtxt += txt.substring(prev,txt.length)
 return newtxt 
} // plustospace()


function Get_Cookie(name) {
 var start = document.cookie.indexOf(name+"=");
 if ((!start) && (name != document.cookie.substring(0,name.length))) return "";
 if (start == -1) return "";
 var len = start+name.length+1;
 var end = document.cookie.indexOf(";",len);
 if (end == -1) end = document.cookie.length;
 return unescape(document.cookie.substring(len,end));
}

// qStr = "_" +queryField("vendor"); <-- ed. BH
qStr="_"+Get_Cookie("vendor");
if (qStr=="_none" | qStr=="_" | qStr=="" | qStr==null) qStr="";
//strip the #sign
var aStr=qStr.replace(/[#]/g,'');
var vouStr= aStr.replace(/^[^a-zA-Z0-9]+/g,'');
if (vouStr == "") vouStr="none";


function animate_title(){

var $spans = $("#overlay span");

$spans.eq(0).fadeIn(3500,function(){
	$spans.eq(1).fadeIn(3500,function(){
		$spans.eq(2).fadeIn(3500,function(){
			$spans.not(":eq(3)").fadeOut(2000,function(){
				$spans.eq(3).fadeIn(2000);
			});
		});
	});
});

}

$(function(){

if(window.location.search == "?failed_login"){

    $('form .detailtext').html("<span id='failed_login_msg'>You have entered a wrong email or password. Please try again.").animate({opacity:0.15},300,function(){
    $(this).animate({opacity:1},300)
});


}
    

$('#loginpanel form input[name="email"], #loginpanel form input[name="password"]').focus(function(){
	$(this).val('');
});

$('#loginpanel form input[name="email"]').blur(function(){
	if($(this).val() == '')  $(this).val('email');
	});
	
$('#loginpanel form input[name="password"]').blur(function(){
	if($(this).val() == '')  $(this).val('password');
});

$("ul.list li").hover(
    function(){$(this).addClass("hover");},
    function(){$(this).removeClass("hover");})
.click(function(){
    $(this).siblings('li').removeClass("selected");
    var i = $(this).addClass("selected").prevAll("li").length;
    var $x = $(this).parent().next().children();
    $x.filter("div:visible").fadeOut( 500,function(){
 	$x.eq(i).fadeIn();
    });
    
    $("#pwcloginbutton").click(function(){
    	var newwin = window.open("https://knowledgecurve.com/nslocal/us/outlook.jsp","Outlook");
    	newwin.focus();
	});


    $("#embargo").jqmAddTrigger(".embargo");
   
});

});
