// Function removes the text from a text field on focus
function RemoveEmail(TextBox)
{
    if (TextBox.value == "E-mail Address")
    {
        TextBox.value = "";
    }
}






// Function resets the text field e-mail address
function ResetEmail(TextBox)
{
    if (TextBox.value == "")
    {
        TextBox.value = "E-mail Address";
    }
}






// Function removes the search box
function RemoveSearch(TextBox)
{
    if (TextBox.value == "Enter Keyword")
    {
        TextBox.value = "";
    }
}






// Function resets the search box
function ResetSearch(TextBox)
{
    if (TextBox.value == "")
    {
        TextBox.value = "Enter Keyword";
    }
}






// Javascript function for showing the captcha explanation
function ShowCaptcha()
{

    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 440) / 2);
    var PageLeft = ((PageWidth - 440) / 2);
        
    
    // Open up the new window
    window.open("/asy/Dynamic/Captcha/codeverification.html", "null", "width=440, height=440, top=" + PageTop + ", Left=" + PageLeft + "location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");


}






// Javascript opens up a starchart window
function ShowStarChart(ArticleID)
{


    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 700) / 2);
    var PageLeft = ((PageWidth - 875) / 2);
    
    
    // Open up the new window
    window.open("/asy/atlas.aspx?c=a&id=" + ArticleID, "null", "width=875, height=700, top=" + PageTop + ", left=" + PageLeft + ",location=no, menubar=no, resizeable=yes, status=no, titlebar=yes, toolbar=no, scrollbars=yes");


}





// Javascript function for showing the gallery image
function ViewMedia(ID)
{
    
    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 525) / 2);
    var PageLeft = ((PageWidth - 550) / 2);
    
    // Open up the new window
    window.open("/asy/dynamic/galleryimage.aspx?id=" + ID, "null", "width=550, height=525, top=" + PageTop + ", left=" + PageLeft + ", location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");    
}






// Javascritp function indicates an invalid captcha control
function InvalidCaptcha()
{
    window.alert("Invalid validation code entered");
}






// Javascript function for the tell a friend onclick event
function TellFriend()
{


    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 500) / 2);
    var PageLeft = ((PageWidth - 600) / 2);
    
    
    // Grab the current url that we are on
    var CurrentURL = location.href;
    CurrentURL = CurrentURL.replace(/&/, "%26");
    var NewURL = "Dynamic/TellFriend.aspx?from=" + CurrentURL;
    
    
    // Open up the new window
    window.open(NewURL, "null", "width=600, height=500, top=" + PageTop + ", Left=" + PageLeft + "location=yes, menubar=yes, resizeable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes");


}






// Javascript function for opening the issue preview flash application window
function PreviewIssue()
{


    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 430) / 2);
    var PageLeft = ((PageWidth - 660) / 2);
    
    
    // Open the new window
    window.open("/asy/dynamic/issuepreview.aspx", "null", "width=660, height=430, left=" + PageLeft + ", top=" + PageTop + ", location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");


}






// Javascript function for opening the issue preview flash application window
function PreviewSIP()
{


    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - 430) / 2);
    var PageLeft = ((PageWidth - 660) / 2);
    
    
    // Open the new window
    window.open("/asy/dynamic/sippreview.aspx", "null", "width=660, height=430, left=" + PageLeft + ", top=" + PageTop + ", location=no, menubar=no, resizeable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");


}






// Javascript function for viewing larger images
function ViewImage(ImgWidth, ImgHeight, ImgPath)
{


    // Grab the current page height
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    
    // Determine the top and left positions
    var PageTop = ((PageHeight - ImgHeight) / 2);
    var PageLeft = ((PageWidth - ImgWidth) / 2);
    
    
    // Open up the new window
    window.open(ImgPath, "null", "width=" + ImgWidth + ", height=" + ImgHeight + ", top=" + PageTop + ", left=" + PageLeft + ", location=no, menubar=no, resizeable=no, scrollbars=no, titlebar=no, toolbar=no");


}







// Function validates an e-mail address
function ValidateForm(){
	var emailID=document.NewsletterBox.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("E-mail Address is Required to Register")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 
 
 
 
 
 // Function validates an e-mail address and coincides with function ValidateForm()
 function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address Entered")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address Entered")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address Entered")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address Entered")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address Entered")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address Entered")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address Entered")
		    return false
		 }

 		 return true					
	}
	
	// Function fixes the transparent png on IE 6
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}