	function extractHTML(html){
		var start = html.indexOf("<div id=\"emailToFriendStart\"></div>");
		var end = html.indexOf("<div id=\"emailToFriendEnd\"></div>");
		var newText = html.substring(start, end);
		newText.replace("<div id=\"emailToFriendStart\"></div>", "");
		return newText;
	}
	
	function emailToFriend(url) {	
		$.ajax({
		  type: "GET",
		  url: url,
		  cache: false,
		 // data: pars,
		  dataType: "html",
		  success: function(html) { 	 
		  	openDialog(extractHTML(html));
		  },
		  error: function(msg) {
		  	//alert ("Error msg from server:" + msg);
		  	openDialog("There was an error while processing your request.");
		  }
		});	
	}
	
	
	function openDialog(html) {
		var closeRow = "<table width=\"100%\" bgcolor=\"#cdcccf\"><tr><td><span style=\"color: #333333; font-size: 13px; font-weight:bold;font-family: Invesco Interstate, Interstate, Verdana, Arial;\">Email to a Friend</span></td><td align=\"right\"> <a href=\"#\" id=\"closeDialogButton\" onclick=\"tb_remove()\"><img src=\"/portal/images/us/close-button.gif\" border=\"0\" /></a> </td></tr></table>";
		html = closeRow + html;
		$('#emailtofriendDialogInsert').html(html);
		var url = "#TB_inline?height=550&width=700&inlineId=emailtofriendDialogContent&modal=true";
		tb_show("Email to Friend", url);	
		return false;
	}
	
	function emailToFriendINA(url) {
		$.ajax({
		  type: "GET",
		  url: url,
		  cache: false,
		 // data: pars,
		  dataType: "html",
		  success: function(html) { 	 
		  	openDialogINA(extractHTML(html));
		  },
		  error: function(msg) {
		  	//alert ("Error msg from server:" + msg);
		  	openDialogINA("There was an error while processing your request.");
		  }
		});	
	}
	
	function openDialogINA(html) {
		var closeRow = "<table width=\"700\" bgcolor=\"#cdcccf\"><tr><td><span style=\"color: #333333; font-size: 13px; font-weight:bold;font-family: Invesco Interstate, Interstate, Verdana, Arial;\">Email Information</span></td><td align=\"right\"> <a href=\"#\" id=\"closeDialogButton\" onclick=\"tb_remove()\"><img src=\"/portal/images/us/close-button.gif\" border=\"0\" /></a> </td></tr></table>";
		html = closeRow + html;
		$('#emailtofriendDialogInsert').html(html);
		var url = "#TB_inline?height=550&width=700&inlineId=emailtofriendDialogContent&modal=true";
		tb_show("Email Information", url);	
		return false;
	}
	function submitForm() {
			var actionUrl = $('#actionUrl').val();
			//alert("actionUrl=" + actionUrl);
			var pars = $('#emailToFriendForm').serialize();
			$.ajax({
			  type: "POST",
			  url: actionUrl,
			  data: pars,
			  cache: false,
			  dataType: "html",
			  success: function(html) {	
				openDialog(extractHTML(html));
			  },
			  error: function(msg) {
			  	alert ("Error msg from server:" + msg);
			  	openDialog("There was an error while processing your request.");
			  	return false;
			  }
			});	
	}

	function submitINAForm() {
	//if($('#privacyCheck').is(":checked")){
			var actionUrl = $('#actionUrl').val();
			//alert("actionUrl=" + actionUrl);
			var pars = $('#emailToFriendForm').serialize();
			$.ajax({
			  type: "POST",
			  url: actionUrl,
			  data: pars,
			  cache: false,
			  dataType: "html",
			  success: function(html) {	
				openDialogINA(extractHTML(html));
			  },
			  error: function(msg) {
			  	alert ("Error msg from server:" + msg);
			  	openDialog("There was an error while processing your request.");
			  	return false;
			  }
			});	
		//}else{
//		alert("Please read and acknowledge the Invesco's Privacy Policy prior to proceding further");
//		}
	}

