// 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 opens the enlarged stardome application
function EnlargeStarDome()
{


    // Grab the current page height and width
    var PageHeight = screen.height;
    var PageWidth = screen.width;
    
    
    
    // Create the URL for new window
    var URL = "stardomeplus.aspx?w=" + PageWidth + "&h=" + PageHeight;
    var Properties = "width=" + PageWidth + ", height=" + PageHeight + ", resizeable=1";
    
    
    
    // Open up the new window
    window.open(URL, "null", Properties);


}





// 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 - 425) / 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=425, 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 - 467) / 2);
    var PageLeft = ((PageWidth - 800) / 2);
    
    
    // Open the new window
    window.open("/asy/dynamic/issuepreview.aspx", "null", "width=800, height=467, 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					
	}