//this function works for textarea in the Submitbio.php
function limitText(limitField, limitCount, limitNum) 
{
	if (limitField.value.length > limitNum) 
	{ 
		limitField.value = limitField.value.substring(0, limitNum);
	} 
	else 
	{
		limitCount.value = limitNum - limitField.value.length;
	}
}

//this function works for textarea in the Submitbio.php
function validate()
{
	if (!document.form.author_firstname.value)
	{
		alert( "Please enter your first name." );
		document.form.author_firstname.focus();
		return false ;
	}
	else if (!document.form.author_lastname.value)
	{
		alert( "Please enter your last name." );
		document.form.author_lastname.focus();
		return false ;
	}
	else if (!document.form.author_phone.value)
	{
		alert( "Please enter your phone number, 10 digits excluding brackets and dashes." );
		document.form.author_phone.focus();
		return false ;
	}
	else if(!document.form.author_email.value) 
	{
		alert( "Please enter your email address." );
		document.form.author_email.focus();
		return false ;
	}
	else if (!document.form.first_name.value)
	{
		alert( "Please enter the person's first name." );
		document.form.first_name.focus();
		return false ;
	}
	else if (!document.form.last_name.value)
	{
		alert( "Please enter the person's last name." );
		document.form.last_name.focus();
		return false ;
	}
	else if (!document.form.limitedtextarea.value)
	{
		alert( "Please supply the biography." );
		document.form.limitedtextarea.focus();
		return false ;
	}
	else
	{
		if(document.form.author_email.value)
		{
			var email_value = document.form.author_email.value;
			var atloc=email_value.indexOf("@",1);
			var dotloc=email_value.indexOf(".",atloc+2);
			var len=email_value.length;
			if(!(atloc>0 && dotloc>0 && len > dotloc+2))
			{
				alert("Please enter your proper email address format.");
				document.form.author_email.focus();
				return false;
			}
		}
		if(document.form.author_phone.value)
		{
			var phone = document.form.author_phone.value;
			//alert("your number is " + phone );
			if(isNaN(phone))
			{
				alert("Please enter a valid number, 10 digits excluding brackets and dashes.");
				document.form.author_phone.focus(); 
				return false;
			}
			else 
			{
				if (phone.length < 10)
				{
					alert("Please enter a ten digit phone number. Omit all spaces, brackets and dashes.");
					document.form.author_phone.focus(); 
					return false;
				}
			}
  		}
		return true ;
  	}
}
 
//function that swaps pictures
function Switch(imgName,imgObjName) 
{
  if (document.images) 
  {
   document.images[imgName].src = eval(imgObjName + ".src");
  }
}

//Adds lines to bottom of page
function AddtoBottom(parags)
{
    bName = navigator.appName;
    bVer = parseInt(navigator.appVersion);
    if (bName =="Netscape" && (bVer < 7))
    {
        for (var i=0; i < parags; i++)
        {
            document.write("<p>&nbsp;</p>");
        }
    }
}

//Function to open new windows
function openWin(URL, Width, Height)
{

aWindow=window.open(URL,"PopUp","width="+Width+",height="+Height+",resizable=yes,scrollbars=yes,left=100,top=60");
    
    aWindow.resizeTo(Width, Height);
    
    aWindow.focus();
    if(aWindow.opener == null)
    {
        aWindow.opener = window;
        aWindow.opener.name = "opener";
    }

}


//Function for comfirmation on buttons
function confirmSubmit()
{
var agree=confirm("Are you sure you want to delete record?");
if (agree)
  return true ;
else
  return false ;
}
//function to redirecto to a different page.
function redirect(page)
{
   var pg = "admin.php?pg=" + page;
   //alert (page);
   document.location = pg;
}
//function to redirecto to a different page with out admin.php?ph= before string.
function fullredirect(page)
{
   var pg = page;
   //alert (page);

   document.location = pg;
}
function image_popup(image,width,height,origLeft,origTop) 
{
	height += 24;
	width += 24;
	image_window = window.open(image,'image','height=' + myHeight + ',width=' + myWidth + ',toolbar=no,directories=no,status=no,' +  'menubar=no,scrollbars=no,resizable=no');
	TheImgWin.resizeTo(width+2,height+30);
	TheImgWin.moveTo(origLeft,origTop);
	TheImgWin.focus();
}



// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width+10,height+10);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}
