function findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function showHideLayers() { //v6.0
	  var i,p,v,obj,args=showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}


//bookmark site

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
	
}

//open internal external link
function openInternalWin(product, url) {
    if(! confirm("Thank you for visiting " + product + ".com.\n\nYou are now being connected to another site.\n\nDo you wish to continue?"))
        return;

    var externalWin = window.open(url,null,"toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500");
    if (externalWin.opener == null)
        externalWin.opener=window;
        externalWin.opener.name="opener";
}

function clear_form()
{
	 	 //clears text boxes
	  document.frmMain.fromEmail.value = '';
	  document.frmMain.toEmail.value ='';
	  document.getElementById("shareFriend").style.visibility = "hidden";
	  
}

//validate send to a friend

function Validate(theForm)
		{
		var goodEmail1 = theForm.fromEmail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		var goodEmail2 = theForm.toEmail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
			if (goodEmail1){
			} else {
			   alert('Please enter your valid email address.')
			   theForm.fromEmail.focus();
          		theForm.fromEmail.className="error";
				return(false);
			   }
			
			
			if (goodEmail2){
			} else {
			   alert('Please enter the valid email address of your friend.')
			   theForm.toEmail.focus();
          		theForm.toEmail.className="error";
				return(false);
			   }
			  var theData="";
				theData  = "?formname="+ theForm.formname.value;
				theData += "&reqf="   + theForm.reqf.value;
				theData += "&emailAFriend=true";
				theData += "&subject=" + theForm.subject.value;
				theData += "&toEmail=" + theForm.toEmail.value;
				theData += "&fromEmail=" + theForm.fromEmail.value;
				theData += "&emailFile="+theForm.emailFile.value;
				
				theForm.toEmail.value = " ";
				theForm.fromEmail.value = " ";
				var theAction = theForm.getAttribute("action");

				var externalWin = window.open(theAction+theData,null,"width=502px,height=250px");
				document.getElementById('shareFriend').style.visibility = 'hidden';
			}
			// if (document.frmMain.fromEmail.value=='')
			//	{alert("Please enter your email address.");
          	//	document.frmMain.fromEmail.focus();
          	//	document.frmMain.fromEmail.className="error";
			//	return(false);
			//	}
			// if (document.frmMain.toEmail.value=='')
			//	{alert("Please enter the email address of your friend.");
			//	document.frmMain.toEmail.focus();
			//	document.frmMain.toEmail.className="error";
			//	return(false);
			//	}
		// }
	
	function getFocus()
	{
	document.frmMain.FirstName.focus();
	}