$(document).ready(function(){
	$("#nav").mouseover(function(){$(this).css({"height":"155px"})}).mouseout(function(){$(this).css({"height":"30px"})});

	$(".download4 > ul > li>p").css({
		"cursor": "pointer",
		"position": "relative"
	});
	$("#fileName4").css({
		"color": "blue",
		"font-weight":"bold"
	})
	$("#dClose4").click(function(){
		$("#floatDownload4").hide("slow");
	});
	$("#floatDownload4>form>ul>li:last").css({"text-align":"", "padding-top":"3px", "line-height":"20px"});
	$("#floatDownload4>form>ul>li").css({"padding-left":"3px"});
	$("#floatDownload4").css({
		
				"display":"none",
		"left":"60px",
		"top":"150px",
		"background":"#FFFFFF",
		"width":"175px",
		"line-height":"0px"
	});
var pn = document.location.pathname;
var p_n = pn.split("/");
if(p_n.length>2){
	$("#floatDownload4").css({"left":"10px"});
}
	$(".download4 > ul > li>a").click(function(){
		var link = $(this).attr("href")||"";
		$("#fileLink4").val(link);
		$("#status4").html("");
		var user = $("#userName4").val("");
		var mail = $("#email4").val("");
		var fileName = $("p",this).html();
		document.getElementById("fileName4").innerHTML = fileName;
		$("#floatDownload4").show("slow");
		return false;
	});
	$("#pdfDown6").click(function(){
		var link = $(".download4 > ul > li>a:last").attr("href")||"";
		$("#fileLink4").val(link);
		$("#status4").html("");
		var user = $("#userName4").val("");
		var mail = $("#email4").val("");
		var fileName = $("p",$(".download4 > ul > li>a:last")).html();
		document.getElementById("fileName4").innerHTML = fileName;
		$("#floatDownload4").show("slow");
		return false;
		
	});
	
	$("#downloadFile4").click(function(){
		var fileName = $("#fileName4").html();
		var user = $("#userName4").val();
		var mail = $("#email4").val();
		//var code = $("#code4").val();	
		if(!user || !mail ){
			$("#status4").html("<span style='color: red;'>One or more of the following fields needs to be completed:<br /><b>*Your Name<br />*Your Email</b></span>");
			return false;
		}

		
		var outOfService = ["@dd.com"];
		var startP = mail.indexOf("@");
		if(startP == -1){
			$("#status4").html("<span style='color:red'><b>Error notice:</b><br />Error email format.</span>");
			return false;
		}
		var mailEnd = mail.substring(mail.indexOf("@"));
		if($.inArray(mailEnd,outOfService) != -1){
			$("#status4").html("<span style='color:red'><b>Error notice:</b><br />Please submit an email address within your corporation or organization.</span>");
			return false;
		}
			$("#downloadFile4").hide();
			document.location = "/download.php?file=Sovereign_Wealth_Fund_Brief_Report.pdf";
		$("#status4").html("<span style='color:green'><b>Your request is being processed. Please wait ...</b></span>");
        		$.post("/4download4.php",{ "userName4":user, "mail4":mail  },  function(xml){
			if($("isok", xml).text()>0){
											$("#floatDownload4").hide("slow");
								
			}
			else {
				window.confirm("Failed!");
				$("#floatDownload4").hide("slow");
			}
		});
			
	});

});

