function contactMe()
{
    var user = "kenneth" + ".chan";
    var site = "letsgooutdoors" + "." + "com";
    window.open('mailto:' + user + '@' + site + '?subject=From LetsGoOutdoors.com');
}
function getDate()
{
	var mn = new Array("Jan","Feb","Mar","April","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var wd = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

	var dt = new Date();
  	var da = dt.getDay();
	var mo = dt.getMonth();

	document.write(wd[da] +", "+ dt.getDate()+" "+mn[mo]+" "+(dt.getFullYear()));
}

function winPopup(fn,w,h)
{
	var win;

	if(document.all)
	{
		//ie

		w += 38;
		h += 48;

		if((window.screen)&&(w>screen.width-10))
			w = screen.width-10;
		if((window.screen)&&(h>screen.height-10))
			h = screen.height-10;
		win = window.open(fn, "links", "menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=" + w + ",height=" + h);
	}

	else
	{
		//nav

		w += 16;
		h += 32;

		if((window.screen)&&(w>screen.width-10))
			w = screen.width-10;
		if((window.screen)&&(h>screen.height-10))
			h = screen.height-10;
		win = window.open(fn, "links", "menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,screenY=0,sceenX=0,width=" + w + ",height=" + h);
	}
	win.focus();
	
}

function picPopup(fn,w,h)
{
	var win;

	if(document.all)
	{
		//ie

		w += 38;
		h += 48;

		if((window.screen)&&(w>screen.width-10))
			w = screen.width-10;
		if((window.screen)&&(h>screen.height-10))
			h = screen.height-10;
		win = window.open(fn, "pic", "scrollbars=yes,resizable=yes,top=0,left=0,width=" + w + ",height=" + h);
	}

	else
	{
		//nav

		w += 16;
		h += 32;

		if((window.screen)&&(w>screen.width-10))
			w = screen.width-10;
		if((window.screen)&&(h>screen.height-10))
			h = screen.height-10;
		win = window.open(fn, "pic", "scrollbars=yes,resizable=yes,screenY=0,sceenX=0,width=" + w + ",height=" + h);
	}

	win.resizeTo(w+10,h+15);
	win.focus();
}

function imgswap(imgname,imgfile)
{
	document.images[imgname].src = imgfile;
}

function refresh()
{

	var sURL = unescape(window.location.pathname);
	var isIE = navigator.userAgent.toLowerCase().indexOf("msie")!=-1;
	var isWWW = document.location.href.toLowerCase().indexOf("http://www.letsgooutdoors.com")==0;

	if(isIE && isWWW)
	{
		sURL = "http://www.letsgooutdoors.com" + sURL;
	}
	Window.location.replace(sURL);
}

function setCookie(cookieName, cookieValue, nDays)
{
	var today = new Date();
	var expire = new Date();

	if (nDays==null || nDays==0)
		nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString()+";path=/";
}

function switchStyle(name)
{
	setCookie("style", name, 1);
	refresh();
}

function calculate(obj, form) 
{
    with (form) 
    {
       if (U2.options[U2.selectedIndex].value != 0 && isnum(V1.value))
            V2.value = V1.value * U1.options[U1.selectedIndex].value / U2.options[U2.selectedIndex].value;
    }
}

function tempconvert(obj,form) 
{
    with (form) 
    {
	var u1val = U1.options[U1.selectedIndex].value;
        var u2val = U2.options[U2.selectedIndex].value;
        var ab0c  = 273.2 * 1;
        var T1    = V1.value * 1
        var T2    = 1 * 1 - 1;
	
	if (isnum(V1.value)) 
	{ 
		if (u1val == u2val) 
		{
			T2 = T1;
		}
		else if (u2val == 1) 
		{
			if (u1val == 2) 
			{
				T2 = (T1 - 32)*5/9;
			
			}
			else  
			{
				T2 = T1 - ab0c;
			}
		}
		else if (u2val == 2) 
		{
			if (u1val == 1) 
			{ 
				T2 = T1 * 9/5 + 32;
			}
			if (u1val == 3) 
			{ 
				T2 = (T1 - ab0c) * 9/5 + 32;
			}
		}
		else if (u2val == 3) 
		{
			if (u1val == 1) 
			{ 
				T2 = (ab0c + T1);
			}
			else 
			{ 
				T2 = (ab0c + (T1 - 32) * 5/9 ) * 1;
			}
		}
		
		V2.value = T2;	
				
	}
    }
}				

function windchill(form) 
{
	wind = eval(form.wind.value);
	temp = eval(form.temp.value);
	
	if(isnum(wind) && isnum(temp)) 
	{
        	chill = (0.045 * (5.27 * (Math.pow(wind, 0.5)) + 10.45 - 0.28 * wind) * (temp - 33) + 33);
        	form.chill.value = twodp(Math.round(chill * 100) / 100);
	}
}

function PressureAtAltitude(form)
{
	var T0 = form.TemperatureAtSeaLevel.value * 1.0 + 273.2;  //K Temperature at sea level
	var P0 = form.PressureAtSeaLevel.value * 1;               //hpa Pressure at sea level

	var z = form.Altitude.value * 1;                          //altitude can be null
        var R = 8314 * 1.0;                                       //R in J K-1 mol-1 gas constant

	var Ma = 28.96 * 1.0;                                     //g mol-1 molecular weight of air
	var g  = 9.82 * 1.0;                                      //m s-2 acceleration due to garvity


	if (isnum(z) && isnum(P0) && isnum(T0) ) 
	{
		pwr = -g * z / ((2 * T0 - z / 200) / 2 * R / Ma);
		P   = P0 * Math.exp(pwr);
		form.PressureatAltitude.value = parseInt(P);
	}
}

function isnum(num) 
{
    if ( num == "" ) 
    {
        return false;
    }

    for (var i = 0; i < num.length; i++) 
    {
       var ch = num.substring (i, i + 1)
       if ((ch < "0" || ch > "9" ) && ch != "." && (i>1 && ch =="-") ) 
       {
       	            return false;
       }
    }
    return true;
}
 
function twodp(n) 
{
    var ns = n.toString();
    var dp = ns.indexOf(".");
    
    if (dp < 0) 
    	ns = ns+".00";
    else if (dp == ns.length-2) 
    	ns = ns+"0";
    else if (dp < ns.length-1) 
    	ns = ns.substring(0,dp+3);
   
   return ns;
}

