function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImage2() { //v3.0
  var i,j=0,x,a=MM_swapImage2.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.bSrc) x.bSrc=x.src; x.src=a[i+2];}
}

function mask(end,middle,start,subject){
var one ='mai';
var two='lto:';
var three='?Subject=';
//start,middle,end,subject;
var putogether= one+two+start+middle+end+three+subject;
document.location.href=eval('"'+putogether+'"');
window.status=putogether;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="inherit";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}

//Customized to delay before closing, also must include onmouseover="clearTimeout(TO);" in the div.
var menudiv;
var TO;
function P7_hideDiv(evt) { //v1.3 by PVII
 var relT,mT=false; 
 if(document.layers){menudiv=evt.target;if(menudiv.p7aHide){
  TO=setTimeout('menudiv.style.visibility=\'hidden\';',750)}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){menudiv=event.srcElement;
  while(menudiv!=null){if(menudiv.tagName=="DIV" && menudiv.p7ahD){mT=true;break;}menudiv=menudiv.parentElement;}
  if(!menudiv.contains(event.toElement)){TO=setTimeout('menudiv.style.visibility=\'hidden\';',750)}
 }else if(document.getElementById){menudiv=evt.currentTarget;relT=evt.relatedTarget;
  while(relT!=null){if(menudiv==relT){mT=true;break;}
  relT=relT.parentNode;}if(!mT){TO=setTimeout('menudiv.style.visibility=\'hidden\';',750)}}
}

function P7_autoHide() { //v1.3 by PVII
 var i,g,args=P7_autoHide.arguments;
 for(i=0;i<args.length;i++){if((g=MM_findObj(args[i]))!=null){
  g.p7aHide=true;if(document.layers){
  g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideDiv;g.p7ahD=true;}}
}

function fadecontent(contentfile,urlvars) {
	new Effect.Fade('maincontent',{duration:0.8,afterFinish: function() { new Ajax.Updater('maincontent','/content/' + contentfile + '.php?directload=1' + urlvars + '', {asynchronous:true, evalScripts:true, onComplete: function(){new Effect.Appear('maincontent');}} ) } });
}

function loadcontent(contentfile) {
	new Ajax.Updater('maincontent','content/' + contentfile, {asynchronous:true});
}

function morphbg(color) {
	new Effect.Morph('colorbox',{ style:'background:' + color, duration:1.0 });
}

var oldtextid = 0;

function morphtext(color,textid,newimage) {
	new Effect.Morph('colorbox',{ style:'background:' + color, duration:1.0 });
	if(oldtextid!=0){new Effect.Morph(oldtextid,{ style:'font-size:12px', duration:0.5 });}
	new Effect.Morph(textid,{ style:'font-size:20px', duration:0.5 });
	new Effect.Fade('pictrans',{duration:0.8,afterFinish: function() {MM_swapImage2('transpic','',''+newimage+'',1);new Effect.Appear('pictrans',{duration:0.8}) }});
	oldtextid = textid;
}



var lastitemdes = 0;
var olditemnameid = 0;

function openitem(itemdes,color,newimage,testid,nameid) {
if(itemdes!=lastitemdes){
	var xPos = document.getElementById(testid).offsetHeight;
    document.getElementById(itemdes).style.height = xPos + 'px';
    if(olditemnameid!=0){new Effect.Morph(olditemnameid,{ style:'font-size:12px', duration:0.5 });}
    new Effect.Morph(nameid,{ style:'font-size:16px', duration:0.5 });
    new Effect.Morph('colorbox',{ style:'background:' + color, duration:1.0 });
	new Effect.SlideDown(itemdes,{ duration:0.5 });

	if(lastitemdes!=0){new Effect.SlideUp(lastitemdes,{ duration:0.5 });}
	new Effect.Fade('pictrans',{duration:0.8,afterFinish: function() {MM_swapImage2('transpic','',''+newimage+'',1);setTimeout('new Effect.Appear(\'pictrans\',{duration:0.8})',500); }});
	olditemnameid = nameid;
	lastitemdes = itemdes; }
}

function loaditem(itemdes,color,newimage,testid,nameid) {
    new Effect.Morph('colorbox',{ style:'background:' + color, duration:1.0 });
	new Effect.Fade('pictrans',{duration:0.8,afterFinish: function() {MM_swapImage2('transpic','',''+newimage+'',1);new Effect.Appear('pictrans',{duration:0.8,afterFinish: function() {loadopenitem(itemdes,color,newimage,testid,nameid)}}) }});
}

function loadopenitem(itemdes,color,newimage,testid,nameid) {
	var xPos = document.getElementById(testid).offsetHeight;
    document.getElementById(itemdes).style.height = xPos + 'px';
 	new Effect.Morph(nameid,{ style:'font-size:16px', duration:0.5 });
	new Effect.SlideDown(itemdes,{ duration:0.5 });
	olditemnameid = nameid;
	lastitemdes = itemdes;
}



var lastcondes = 0;
var oldconnameid = 0;

function clearcon() {
lastcondes = 0;
oldconnameid = 0;
}

function openconsult(condes,testid,nameid) {
if(condes!=lastcondes){
	var xPos = document.getElementById(testid).offsetHeight;
    document.getElementById(condes).style.height = xPos + 'px';
  	if(oldconnameid!=0){new Effect.Morph(oldconnameid,{ style:'font-size:12px', duration:0.5 });}
    new Effect.Morph(nameid,{ style:'font-size:16px', duration:0.5 });
	new Effect.SlideDown(condes,{ duration:0.5 });
	if(lastcondes!=0){new Effect.SlideUp(lastcondes,{ duration:0.5 });}
	oldconnameid = nameid;
	lastcondes = condes; }
}

function start_slideshow(start_frame, end_frame, delay) {
        setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
    }
                            
    function switch_slides(frame, start_frame, end_frame, delay) {
        return (function() {
            Effect.Fade('slideshow' + frame);
            if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
            setTimeout("Effect.Appear('slideshow" + frame + "');", 850);
            setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
        })
    }
    
    function signup() {
    	if((document.getElementById('firstname').value!='')&&(document.getElementById('lastname').value!='')&&(document.getElementById('email').value!='')) { new Ajax.Updater('nlform', '/display/content/scripts/register_submit.php', {asynchronous:true, parameters:Form.serialize(this)}); return false;}else{alert('All fields are required.'); return false; }
    
    }
