//Generate Pop-up Div
function leavingWebsite(url, target){
if(!document.getElementById("popupDiv")){
	window.scrollTo(0,0);
	
	var strInnerHTML = "<table summary=\"popupHolder\">";
	strInnerHTML += "<tr>";
	strInnerHTML += "<td colspan=\"2\"><strong>NOTICE: You are currently leaving the Secure Government website for a 3rd Party one.</strong></td>";
	strInnerHTML += "</tr>";
	strInnerHTML += "<tr>";
	strInnerHTML += "<td><input type=\"button\" value=\"Continue\" onclick=\"leavingWebsite_Continue('"+url+"','"+ target+"')\"/></td>";
	strInnerHTML += "<td><input type=\"button\" value=\"Cancel\" onclick=\"leavingWebsite_Cancel()\"/></td>";
	strInnerHTML += "</tr>";
	strInnerHTML += "</table>";
	
	var objPopupDiv = document.createElement("div");
    objPopupDiv.setAttribute("id","popupDiv");
    objPopupDiv.style.width = "350px";
    objPopupDiv.style.height = "130px";
    objPopupDiv.innerHTML = strInnerHTML;
    document.body.appendChild(objPopupDiv);
	centerPopup();
	window.onresize = function (){
		centerPopup();
	}
}
}

//Cancel Functionality
function leavingWebsite_Cancel(){
	objPopupDiv = document.getElementById("popupDiv");
	document.body.removeChild(objPopupDiv);
	window.onresize = function (){
		return false;
	}
}

//Continue Functionality
function leavingWebsite_Continue(url, target){
	target = target.toLowerCase();
	if (target=="blank"){
		window.open(url);
	}else{
		eval(target+".location='"+url+"'");
	}
	leavingWebsite_Cancel();
}

//Center Pop-up Div
function centerPopup(){
	objPopupDiv = document.getElementById("popupDiv");
	intWidth = parseInt(document.documentElement.clientWidth) - parseInt(objPopupDiv.style.width);
	intWidth = intWidth / 2;
	objPopupDiv.style.left = intWidth + "px";
	
	intHeight = parseInt(document.documentElement.clientHeight) - parseInt(objPopupDiv.style.height);
	intHeight = intHeight / 2;
	objPopupDiv.style.top = intHeight + "px";
 }
 
 function inputOnFocus(element){
	if(element.value == 'Search...'){
		element.value = '';
		element.style.color = '#000000';
	}
}
function inputOnBlur(element){
	if(element.value == ''){
		element.style.color = '#999999';
		element.value = 'Search...';
	}
}

// Validates text box length
function CheckLength(source,arguments)
{
   if (arguments.Value.length > source.MaximumLength)
   {
    arguments.IsValid = false;
   }else{
    arguments.IsValid = true;
   }
}

function CheckContent(source,arguments)
{
  var reg = new RegExp("[^\\w\\s.\"@',&/?-]");      
  if (reg.test(arguments.Value) == true)
   {
    arguments.IsValid = false;
   }else{
    arguments.IsValid = true;
   }
}

function CheckString(source,arguments)
{
  var reg = new RegExp("[^\\w\\s.\",'-]");

   if (reg.test(arguments.Value) == true)
   {
    arguments.IsValid = false;
   }else{
    arguments.IsValid = true;
   }
}

function doClear(strObjId)
{
 if (strObjId.value === "Search...")
    {
        strObjId.value = "";
    }       
}

function sendemail(email1,email2,email3,subject)
{
    parent.location = 'mailto:' + email1 + '@' + email2 + '.' + email3 + '?subject=' + subject;
}

function renderEmail(email1,email2,email3)
{
    var fullemail = email1 + '@' + email2 + '.' + email3;
    document.write(fullemail);
}