$(document).ready(function() {
	$('.login').click(function() {
  		$(".loginPanel").slideToggle(150);
	});
	
	
});

function pageLoad() {
	var originalValues = new Array();
	
	$('#forgottenPassword').click( function() {
		$(".loginPanel").slideUp(150);
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform');
		$(".forgottenContent").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		return false;
 	});
	
	if ($("#passwordSentError").length > 0) {
	
		$("div.forgottenpassword").delay(3000).slideUp(function () {
			$("div.blackout").delay(500).fadeOut(function () {
				$("div.forgottenContent").appendTo('.forgotContainer');
				$("div.blackout").remove();
				$("div.forgottenpassword").remove();
			});
		});
		
	}
	
	if ($("#passwordSubmitError").length > 0) {
			
	}
	
	if ($("#passedBondnumber").length > 0) {
		if (window.location.search != "?login=true") {
			$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		}
		
		$(".loginPanel").delay(350).slideDown(150);
	}
	
	if ($("#passwordChangeMismatchError").length > 0) {
		
	}
	
	if ($("#badEmailMismatchError").length > 0) {
			
		$("#tbresetBadEmail").val("Email address").css({'background-color':'#d7df23'});
		$("#tbresetBadEmailConfirm").val("Confirm email address");
		
	}
	
	if ($("#passwordMismatchError").length > 0) {

		$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$("#p8787Dummy").hide();
		$("#p8787").show().focus();
	
	};
	
	if ($("#bondnoNotExistError").length > 0) {

		$("#l5129").val("Bond number").css({'background-color':'#d7df23'});

	};
	
	if ($("#blankEmailError").length > 0) {
		
		
		$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$(".loginPanel").slideUp(300, function() {
			$("#l5129").val("Bond number").css({ 'color': "#666", 'font-style': 'italic', 'font-weight': 'normal' });
		});
		
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform');
		$(".submitEmailAddress").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		$("#tbRegisterEmail").css({'background-color':'#eeeeee'});

	};
	
	if ($("#emailMismatchError").length > 0) {
		
		$("#tbRegisterEmail").val("Email address");
		$("#tbRegisterEmailConfirm").val("Confirm email address");
			
	}
	
	
	if ($("#passwordfirstsetErrorFromEmail").length > 0) {
		
		$("#tbRegisterEmail").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$("#tbRegisterEmailConfirm").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		
		$(".forgottenpassword").slideUp( function () { 
			$(".submitEmailAddress").appendTo('.forgotContainer');
			$(".submitPasswordChange").appendTo("div.forgottenpassword");
			$(".forgottenpassword").slideDown();
		});	
		
	};
	
	
	if ($("#passwordfirstsetError").length > 0) {
		
		$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$(".loginPanel").slideUp(300, function() {
			$("#l5129").val("Bond number").css({ 'color': "#666", 'font-style': 'italic', 'font-weight': 'normal' });
		});
		
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform');
		$(".submitPasswordChange").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		
	};
	
	
	
	if ($("#badEmailFromPasswordError").length > 0) {
		
		$(".forgottenpassword").slideUp( function() {
			$(".submitPasswordChange").appendTo('.forgotContainer');
			$(".badEmail").appendTo("div.forgottenpassword");
			$(".forgottenpassword").slideDown();
		});
		
	};
	
	
	if ($("#badEmailError").length > 0) {
		
		$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$(".loginPanel").slideUp(300, function() {
			$("#l5129").val("Bond number").css({ 'color': "#666", 'font-style': 'italic', 'font-weight': 'normal' });
		});
		
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform');
		$(".badEmail").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		
	};
	
	if ($("#loginsuccess1").length > 0) {
		
		$("div.forgottenpassword").slideUp( function() {
			$("div.blackout").delay(500).fadeTo("fast", 1.0, function() {
				$("div.forgottenContent").appendTo('.forgotContainer');
				$("div.forgottenpassword").remove();
				
			});
		})

		$("div.blackout").append("<p class='noRedirect'>If you are not redirected automatically within a few seconds then please <a href='/cgi-bin/success-login.html'>click here</a></p>");
		
		setTimeout('window.location.replace("/cgi-bin/success-login.html")', 800);
		
	};
	
	if ($("#loginsuccess2").length > 0) {
		
		$("tbRegisterEmail").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$("tbRegisterEmailConfirm").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		
		$("div.forgottenpassword").slideUp( function() {
			$("div.blackout").delay(500).fadeTo("fast", 1.0, function() {
				$("div.forgottenContent").appendTo('.forgotContainer');
				$("div.forgottenpassword").remove();
				
			});
		})

		$("div.blackout").append("<p class='noRedirect'>If you are not redirected automatically within a few seconds then please <a href='/cgi-bin/success-login.html'>click here</a></p>");
		
		setTimeout('window.location.replace("/cgi-bin/success-login.html")', 800);
		
	};
	
	if ($("#loginsuccess3").length > 0) {
		
		$(".loginPanel").slideUp(150);
	
		$("<div class='blackout'></div>").hide().css("opacity",1.0).appendTo('body').delay(300).fadeIn();
		
		$("div.blackout").append("<p class='noRedirect'>If you are not redirected automatically within a few seconds then please <a href='/cgi-bin/success-login.html'>click here</a></p>");
		
		setTimeout('window.location.replace("/cgi-bin/success-login.html")', 800);
		
	};
	
	if ($("#loginsuccess4").length > 0) {
		
		$("tbresetBadEmail").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		$("tbresetBadEmailConfirm").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		
		$("div.forgottenpassword").slideUp( function() {
			$("div.blackout").delay(500).fadeTo("fast", 1.0, function() {
				$("div.forgottenContent").appendTo('.forgotContainer');
				$("div.forgottenpassword").remove();
			});
		})

		$("div.blackout").append("<p class='noRedirect'>If you are not redirected automatically within a few seconds then please <a href='/cgi-bin/success-login.html'>click here</a></p>");
		
		setTimeout('window.location.replace("/cgi-bin/success-login.html")', 800);
		
	};
	
	$('#newInvestBonusButton').click( function() {
		
		$("html, body").animate({ scrollTop: 0 }, 500);
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform').css({"width":"700px", "margin":"0 0 0 -350px"});
		$(".newInvestBonus").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		return false;
 	});
	
	
	
	
	
	
	$('#loginNOJQ').attr("href","#").click( function() {
		return false;
	});
		
	$('body').click( function() {
 		if ($(".loginPanel:visible")) {
			$(".loginPanel").slideUp(150);
		}
 	});
	
 	$('.loginPanel, .login').click( function(event){
    	event.stopPropagation();
 	});
	
	
	$('.closePassword').click( function() {
  		
		$(".forgottenpassword").slideUp( function() {
			$('.closePassword').parent().appendTo('.forgotContainer');
			$("div.blackout").delay(500).fadeOut( function() {
				$(this).remove();
				$(".forgottenpassword").remove();
			});
		});
	});

    

    $("input:text").not('#p8787Dummy').not("#p8787").not("#tbNewPasswordDummy").not("#tbNewPasswordConfirmDummy").focus(function () {

        if (!originalValues[this.id]) {
            originalValues[this.id] = $(this).val()
        }

        if ($(this).val() == originalValues[this.id]) {
            $(this).val('').css({ 'color': '#000', 'font-style': 'normal', 'font-weight': 'bold' });
        }
		$(this).css({'background-color':'#d7df23' });
    });

    $("input:text").blur(function () {
        if ($(this).attr("value") == "") {
            $(this).val(originalValues[this.id]).css({ 'color': "#666", 'font-style': 'italic', 'font-weight': 'normal' });
        }
		$(this).css({'background-color':'#EEEEEE' });
    });

	
	$("#p8787Dummy").focus( function () {
        $(this).hide();
        $("#p8787").show().css({ 'background-color': '#d7df23' }).focus();
    });
	
	$("#p8787").focus( function () {
        $(this).css({ 'background-color': '#d7df23' });
    });
	
	$("#p8787").blur( function() {
        if ( $(this).val()=="") {
            $(this).hide();
			$("#p8787Dummy").show();
        }
		$(this).css({'background-color':'#eeeeee' })    
    });
	
	
	
	
	$("#tbNewPasswordDummy").focus( function () {
        $(this).hide();
        $("#tbNewPassword").show().css({ 'background-color': '#d7df23' }).focus();
    });
	
	$("#tbNewPassword").blur( function() {
        if ( $(this).attr("value")=="") {
            $(this).hide();
			$("#tbNewPasswordDummy").show();
        }
		$(this).css({'background-color':'#eeeeee' })    
    });
	
	
	$("#tbNewPasswordConfirmDummy").focus( function () {
        $(this).hide();
        $("#tbNewPasswordConfirm").show().css({ 'background-color': '#d7df23' }).focus();
    });
	
	
	$("#tbNewPasswordConfirm").blur( function() {
        if ( $(this).attr("value")=="") {
            $(this).hide();
			$("#tbNewPasswordConfirmDummy").show();
        }
		$(this).css({'background-color':'#eeeeee' })    
    });






	
	if($("#p8787").length > 0){
		
		$("#p8787").blur( function() {
			if ($("#p8787").val()  == ''){
				$("#CbRememberMe").attr('checked', false);
			}
		});
		
		$("#l5129").blur( function() {
			if ($("#l5129").val()  == ''){
				$("#CbRememberMe").attr('checked', false);
			}
		});
		
		if ($("#p8787").val().length > 0){
			$("#p8787").show();
			$("#p8787Dummy").hide();
			$("#l5129").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
		}
	
	}
	
	
	
	
	
	
	
	if ($("#tbTellFriendYourName").val()!="Your name") {
		$("#tbTellFriendYourName").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
	}
	
	if ($("#tbTellFriendYourEmail").val()!="Your email address") {
		$("#tbTellFriendYourEmail").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
	}
	
	if ($("#tbTellFriendName").val()!="Your friend's name") {
		$("#tbTellFriendName").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
	}
	
	if ($("#tbTellFriendEmail").val()!="Your friend's email address") {
		$("#tbTellFriendEmail").css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
	}
	
	
	$("#tbTellFriendYourName").focus(function() {
        if ( $(this).val()=="Your name") {
            $(this).val('').css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
        } 
		$(this).css({'background-color':'#d7df23' });      
    });
	
	$("#tbTellFriendYourName").blur(function() {
        if ( $(this).attr("value")=="") {
            $(this).val('Your name').css({'color': "#666", 'font-style': 'italic', 'font-weight': 'normal'});
        } 
		$(this).css({'background-color':'#EEEEEE' });    
    });
	
	
	$("#tbTellFriendYourEmail").focus(function() {
        if ( $(this).val()=="Your email address") {
            $(this).val('').css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
        } 
		$(this).css({'background-color':'#d7df23' });      
    });
	
	$("#tbTellFriendYourEmail").blur(function() {
        if ( $(this).attr("value")=="") {
            $(this).val('Your email address').css({'color': "#666", 'font-style': 'italic', 'font-weight': 'normal'});
        } 
		$(this).css({'background-color':'#EEEEEE' });    
    });
	
	
	
	$("#tbTellFriendName").focus(function() {
        if ( $(this).val()=="Your friend's name") {
            $(this).val('').css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
        } 
		$(this).css({'background-color':'#d7df23' });      
    });
	
	$("#tbTellFriendName").blur(function() {
        if ( $(this).attr("value")=="") {
            $(this).val("Your friend's name").css({'color': "#666", 'font-style': 'italic', 'font-weight': 'normal'});
        } 
		$(this).css({'background-color':'#EEEEEE' });    
    });
	
	
	
	$("#tbTellFriendEmail").focus(function() {
        if ( $(this).val()=="Your friend's email address") {
            $(this).val('').css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
        } 
		$(this).css({'background-color':'#d7df23' });      
    });
	
	$("#tbTellFriendEmail").blur(function() {
        if ( $(this).attr("value")=="") {
            $(this).val("Your friend's email address").css({'color': "#666", 'font-style': 'italic', 'font-weight': 'normal'});
        } 
		$(this).css({'background-color':'#EEEEEE' });    
    });
	
	
	
	$("#tbTellFriendMessage").focus(function() {
        if ( $(this).val()=="Message (optional)") {
            $(this).val('').css({'color': "#000", 'font-style': 'normal', 'font-weight': 'bold'});
        } 
		$(this).css({'background-color':'#d7df23' });      
    });
	
	$("#tbTellFriendMessage").blur(function() {
        if ( $(this).attr("value")=="") {
            $(this).val("Message (optional)").css({'color': "#666", 'font-style': 'italic', 'font-weight': 'normal'});
        } 
		$(this).css({'background-color':'#EEEEEE' });    
    });

};

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

