// This is the main JS file for Nouvo's website
//
// version 0.1.001

// My stuff

// Runs when the page loads.
function pageLoad()
{
	// Change the initial button text to the 'Show Notepad' button.
	toggleTextarea('notepad');
}

function pageUnload()
{
	var form=document.iframe_footer_notes;
	if ( form.changes.value == 1 )
	{
		// The footer note was changed but not saved. Save it now.
		document.iframe_footer_notes.submit();
	}
}

// Unlocks on change and locks on click a submit button
function lockOnSubmit(button)
{
	var form=document[button];
	form.save.disabled=true;
	
	// Can we get the element using the standard method?
	var telement='';
	var tvisible='';
	if ( document.getElementById('save') )
	{
		// Woots then!
		telement=document.getElementById('save');
	}
	else if ( document.all )
	{
		// Old IE way... bastards. (no, I'm neutral, why do you ask?)
		telement=document.all['save'];
	}
	else if ( document.layers )
	{
		// Old NN4 way, also bastards. (Hey, they should have been able to see the future! Sheesh...)
		telement=document.layers['save'];
	}
	telement.disabled=true;
	tvisible=telement.style;
	tvisible.color='#7f7f7f';
	form.submit();
}

function noteChanges(formname)
{
	var form=document[formname];
	form.changes.value='1';
}

// Show and Hide the notepad.
function toggleTextarea(tname)
{
	var form=document.footer;
	var telement='';
	var tvisible='';
	var sayTogOn=form.togon.value;
	var sayTogOff=form.togoff.value;
	var sayButton='';
	
	// Can we get the element using the standard method?
	if ( document.getElementById(tname) )
	{
		// Woots then!
		telement=document.getElementById(tname);
		sayButton=document.getElementById('toggle');
	}
	else if ( document.all )
	{
		// Old IE way... bastards. (no, I'm neutral, why do you ask?)
		telement=document.all[tname];
		sayButton=document.all['toggle'];
	}
	else if ( document.layers )
	{
		// Old NN$ way, also bastards. (Hey, they should have been able to see the future! Sheesh...)
		telement=document.layers[tname];
		sayButton=document.layers['toggle'];
	}
	
	// Now toggle!
	tvisible=telement.style;
	if (( tvisible.display == '' ) || ( tvisible.display == 'block' ))
	{
		tvisible.display='none';
		sayButton.value=sayTogOn;
	}
	else
	{
		tvisible.display='block';
		sayButton.value=sayTogOff;
	}
}


// Grabbed stuff

/***********************************************
* Email Validation script-  Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e)
{
	var returnval=emailfilter.test(e.value)
	if (returnval==false)
	{
		alert("Please enter a valid email address. You entered: ["+e.value+"].")
		e.select()
	}
	return returnval
}

function handleEnter (field, event)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} else {
		return true;
	}
}

function pausecomp(millis)
{
	date = new Date();
	var curDate = null;

	do { var curDate = new Date(); }
	while(curDate-date < millis);
}

/* Calls an iFrame */
function callIframe(frameName, frameID, frameHREF)
{
	var frame=getFrame()
}

/* -=] Toot Tips [=- */
<!--
/* Integrated into the main 'nmc.js' file and modified to better suit NMC by Madison Kelly
 
 Pleas leave this notice.
 DHTML tip message version 1.5.4 copyright Essam Gamal 2003 
 Home Page: (http://migoicons.tripod.com)
 Email: (migoicons@hotmail.com)
 Updated on :7/30/2003
*/ 

var MI_IE=MI_IE4=MI_NN4=MI_ONN=MI_NN=MI_pSub=MI_sNav=0;mig_dNav();
var Style=[],Text=[],Count=0,move=0,fl=0,isOK=1,hs,e_d,tb,w=window,PX=(MI_pSub)?"px":""
var d_r=(MI_IE&&document.compatMode=="CSS1Compat")? "document.documentElement":"document.body"
var ww=w.innerWidth
var wh=w.innerHeight
var sbw=MI_ONN? 15:0
var MI_sNav="true";

function mig_hand()
{
	if(MI_sNav)
	{
		w.onresize=mig_re
		document.onmousemove=mig_mo
		if(MI_NN4) document.captureEvents(Event.MOUSEMOVE)
	}
}

function mig_dNav()
{
	var ua=navigator.userAgent.toLowerCase()
	MI_pSub=navigator.productSub
	MI_OPR=ua.indexOf("opera")>-1?parseInt(ua.substring(ua.indexOf("opera")+6,ua.length)):0
	MI_IE=document.all&&!MI_OPR?parseFloat(ua.substring(ua.indexOf("msie")+5,ua.length)):0
	MI_IE4=parseInt(MI_IE)==4
	MI_NN4=navigator.appName.toLowerCase()=="netscape"&&!document.getElementById
	MI_NN=MI_NN4||document.getElementById&&!document.all
	MI_ONN=MI_NN4||MI_pSub<20020823
	MI_sNav=MI_NN||MI_IE||MI_OPR>=7
}

function mig_cssf()
{
	if(MI_IE>=5.5&&FiltersEnabled)
	{
		fl=1
		var d=" progid:DXImageTransform.Microsoft."
		mig_layCss().filter="revealTrans()"+d+"Fade(Overlap=1.00 enabled=0)"+d+"Inset(enabled=0)"+d+"Iris(irisstyle=PLUS,motion=in enabled=0)"+d+"Iris(irisstyle=PLUS,motion=out enabled=0)"+d+"Iris(irisstyle=DIAMOND,motion=in enabled=0)"+d+"Iris(irisstyle=DIAMOND,motion=out enabled=0)"+d+"Iris(irisstyle=CROSS,motion=in enabled=0)"+d+"Iris(irisstyle=CROSS,motion=out enabled=0)"+d+"Iris(irisstyle=STAR,motion=in enabled=0)"+d+"Iris(irisstyle=STAR,motion=out enabled=0)"+d+"RadialWipe(wipestyle=CLOCK enabled=0)"+d+"RadialWipe(wipestyle=WEDGE enabled=0)"+d+"RadialWipe(wipestyle=RADIAL enabled=0)"+d+"Pixelate(MaxSquare=35,enabled=0)"+d+"Slide(slidestyle=HIDE,Bands=25 enabled=0)"+d+"Slide(slidestyle=PUSH,Bands=25 enabled=0)"+d+"Slide(slidestyle=SWAP,Bands=25 enabled=0)"+d+"Spiral(GridSizeX=16,GridSizeY=16 enabled=0)"+d+"Stretch(stretchstyle=HIDE enabled=0)"+d+"Stretch(stretchstyle=PUSH enabled=0)"+d+"Stretch(stretchstyle=SPIN enabled=0)"+d+"Wheel(spokes=16 enabled=0)"+d+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=forward enabled=0)"+d+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=reverse enabled=0)"+d+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=forward enabled=0)"+d+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=reverse enabled=0)"+d+"Zigzag(GridSizeX=8,GridSizeY=8 enabled=0)"+d+"Alpha(enabled=0)"+d+"Dropshadow(OffX=3,OffY=3,Positive=true,enabled=0)"+d+"Shadow(strength=3,direction=135,enabled=0)"
	}
}

/*
0 "white",	Title text colour
1 "#000099",	Title BG colour
2 "",	x	Title BG Image
3 "",		Title Text Align
4 "",		Title Font Face
5 ,		Title Font Size
6 "black",	Body text colour
7 "#e8e8ff",	Body BG colour
8 "",	x	Body BG Image
9 "",		Body Text Align
10 "",		Body Font Face
11 ,		Body Font Size
12 ,		Width
13 ,		Height
14 2,		Border Size
15 "#000099",	Border Colour
16 2,		Text Padding
17 ,	x	IE only - Transition number
18 ,	x	IE only - Transition duration
19 ,	x	IE only - Transparency level
20 ,	x	IE only - Shadow type
21 "",	x	IE only - Shadow color
22 1,		Appearance behavior	(1= Sticky)
23 2,		TipPositionType		(2= ?)
24 ,	x	X-Position
25 	x	Y-Position
*/

function stm(titleText, bodyText, textWidth, textHeight, textBehave, textAlign)
{
	if(MI_sNav&&isOK)
	{
		// These are options used by IE only
		var ieA="";	// s[17] - Transition number
		var ieB="";	// s[18] - Transition duration
		var ieC="";	// s[19] - Transparency level
		var ieD="";	// s[20] - Shadow type
		var ieE="";	// s[21] - Shadow color
		
		// These are the static X-Y position values, not used
		var posX="";	// s[24]
		var posY="";	// s[25]
		
		// Main code
		if(document.onmousemove!=mig_mo||w.onresize!=mig_re) mig_hand();
		if(fl&&ieA>-1&&ieB>0)mig_layCss().visibility="hidden";
		var tipHeight=textHeight? "HEIGHT='"+textHeight+"'":"";
		if(!textWidth)textWidth=200;
		if(!posX)posX=10;
		if(!posY)posY=10;
		hs=textBehave;
		
		var closeLink;
		if (hs==3)
		{
			closeLink="<TD><A HREF='javascript:void(0)' ONCLICK='mig_hide(0)'>Close</A></TD>";
		}
		else
		{
			closeLink="";
		}
		
		var title;
		if (titleText||hs==3)
		{
			title="<TABLE class='table3' WIDTH='100%'><TR><TD class='td3'>"+titleText+"</TD>"+closeLink+"</TR></TABLE>";
		}
		else
		{
			title="";
		}
		
		var txt="<TABLE class='table1' WIDTH='"+textWidth+"'><TR><TD class='td1'>"+title+"<TABLE WIDTH='100%' "+tipHeight+" class='table2'><TR><TD class='td2'>"+bodyText+"</TD></TR></TABLE></TD></TR></TABLE>"
//		alert('txt: ['+txt+']');
		mig_wlay(txt)
		tb={trans:ieA,dur:ieB,opac:ieC,st:ieD,sc:ieE,pos:textAlign,xpos:posX,ypos:posY}
		if(MI_IE4)mig_layCss().width=textWidth
		e_d=mig_ed()
		Count=0
		move=1
	}
}

function mig_mo(e)
{
	if(move)
	{
		var X=0,Y=0,s_d=mig_scd(),w_d=mig_wd()
		var mx=MI_NN?e.pageX:MI_IE4?event.x:event.x+s_d[0]
		var my=MI_NN?e.pageY:MI_IE4?event.y:event.y+s_d[1]
		if(MI_IE4)e_d=mig_ed()
		switch(tb.pos){
		case 1:X=mx-e_d[0]-tb.xpos+6;Y=my+tb.ypos;break
		case 2:X=mx-(e_d[0]/2);Y=my+tb.ypos;break
		case 3:X=tb.xpos+s_d[0];Y=tb.ypos+s_d[1];break
		case 4:X=tb.xpos;Y=tb.ypos;break		
		default:X=mx+tb.xpos;Y=my+tb.ypos}
		if(w_d[0]+s_d[0]<e_d[0]+X+sbw)X=w_d[0]+s_d[0]-e_d[0]-sbw
		if(w_d[1]+s_d[1]<e_d[1]+Y+sbw){if(tb.pos>2)Y=w_d[1]+s_d[1]-e_d[1]-sbw;else Y=my-e_d[1]}
		if(X<s_d[0])X=s_d[0]
		with(mig_layCss()){left=X+PX;top=Y+PX}
		mig_dis()
	}
}

function mig_dis()
{
	Count++
	if(Count==1)
	{
		if(fl)
		{
			if(tb.trans==51)tb.trans=parseInt(Math.random()*50)
			var at=tb.trans>-1&&tb.trans<24&&tb.dur>0 
			var af=tb.trans>23&&tb.trans<51&&tb.dur>0
			var t=mig_lay().filters[af?tb.trans-23:0]
			for(var p=28;p<31;p++){mig_lay().filters[p].enabled=0}
			for(var s=0;s<28;s++){if(mig_lay().filters[s].status)mig_lay().filters[s].stop()}
			for(var e=1;e<3;e++){if(tb.sc&&tb.st==e){with(mig_lay().filters[28+e]){enabled=1;color=tb.sc}}}
			if(tb.opac>0&&tb.opac<100){with(mig_lay().filters[28]){enabled=1;opacity=tb.opac}}
			if(at||af){if(at)mig_lay().filters[0].transition=tb.trans;t.duration=tb.dur;t.apply()}
		}
		mig_layCss().visibility=MI_NN4?"show":"visible"
		if(fl&&(at||af))t.play()
		if(hs>0&&hs<4)move=0
	}
}

function mig_layCss()
{
	return MI_NN4?mig_lay():mig_lay().style
}

function mig_lay()
{
	with(document)
	{
		return MI_NN4 ? layers[TipId] : MI_IE4 ? all[TipId] : getElementById(TipId)
	}
}

function mig_wlay(txt)
{
	if(MI_NN4)
	{
		with(mig_lay().document)
		{
			open();
			write(txt);
			close()
		}
	}
	else
	{
		mig_lay().innerHTML=txt
	}
}

function mig_hide(C)
{
	if(!MI_NN4||MI_NN4&&C)mig_wlay("");
	with(mig_layCss())
	{
		visibility=MI_NN4?"hide":"hidden";left=0;top=-800
	}
}

function mig_scd()
{
	return [parseInt(MI_IE?eval(d_r).scrollLeft:w.pageXOffset),parseInt(MI_IE?eval(d_r).scrollTop:w.pageYOffset)]
}

function mig_re()
{
	var w_d=mig_wd();
	if(MI_NN4&&(w_d[0]-ww||w_d[1]-wh))location.reload();else if(hs==3||hs==2) mig_hide(1)
}

function mig_wd()
{
	return [parseInt(MI_ONN?w.innerWidth:eval(d_r).clientWidth),parseInt(MI_ONN?w.innerHeight:eval(d_r).clientHeight)]
}

function mig_ed()
{
	return [parseInt(MI_NN4?mig_lay().clip.width:mig_lay().offsetWidth)+3,parseInt(MI_NN4?mig_lay().clip.height:mig_lay().offsetHeight)+5]
}

function htm()
{
	if(MI_sNav&&isOK)
	{
		if(hs!=4)
		{
			move=0;
			if(hs!=3&&hs!=2)
			{
				mig_hide(1)
			}
		}
	}
}

function mig_clay()
{
	var ml=mig_lay();
	if(!ml)
	{
		isOK=0  
		alert("DHTML TIP MESSAGE VERSION 1.5 ERROR NOTICE.\n<DIV ID=\""+TipId+"\"></DIV> tag missing or its ID has been altered")
	}
	else
	{
		mig_hand();
		mig_cssf()
	}
}
-->

