var myWidth = 0;
var myHeight = 0;

function get_window_size() 
{
	if (self.innerWidth)
	{
	
		myWidth = self.innerWidth;
		myHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{

		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body.clientWidth)
	{

		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

}

function set_window_size()
{

	get_window_size();
	screenW = screen.width;
	screenH = screen.height;

	if ( (screenW - 20) < myWidth )
	{
		
		if (window.outerWidth) 
		{
			
			window.outerWidth = (screenW - 20);
		}
		else if (window.resizeTo) 
		{
			window.resizeTo((screenW - 20),myHeight);
		}
	}
	
	get_window_size();

	if ( ( screenH - 20 ) < myHeight )
	{
		
		if (window.outerHeight) 
		{
			window.outerHeight = screenH - 20;
		}
		else if (window.resizeTo) 
		{
			window.resizeTo(myWidth,(screenH - 20));
		}
	}
	
}

function showLayer(layerId,show) {
	if (document.getElementById && document.getElementById(layerId)) { objLayer = document.getElementById(layerId); } else if (document.all && document.all[layerId]) { objLayer = document.all[layerId]; } else if (document.layers && document.layers[layerId]) { objLayer = document.layers[layerId]; } else { objLayer = null; }
	if (objLayer !== null) { objLayer.style.display = (show) ? 'block' : 'none'; }
}

function maps() {
	args=maps.arguments;
	switch (args[0]) {
		case 'corporate':
			window.open('maps.corporate.asp?no_permis='+args[1],'mapcorporate','width=680, height=785, scrollbars=yes, resizable');
			break
		case 'outfitter':
			window.open('maps.outfitters.asp?no_permis='+args[1],'mapoutfitter','width=50, height=50, scrollbars=yes, resizable');
			break
		case 'province':
			switch (args[1]) {
				case 'regions':
					window.open('maps.province.asp','mapprovinceregions','width=799, height=767, scrollbars=yes, resizable');
					break
				case 'zones':
					window.open('maps.province.zones.asp','mapprovincezones','width=798, height=767, scrollbars=yes, resizable');
					break
			}
			break
		case 'region':
			window.open('maps.regions.asp?id='+args[1],'mapregion','width=50, height=50, scrollbars=yes, resizable');
			break
		case 'zone':
			window.open('maps.regions.zones.asp?id='+args[1],'mapregionzone','width=50, height=50, scrollbars=yes, resizable');
			break
	}
}

function profile(no_permis) {
	window.opener.location = 'outfitters.profile.asp?'+no_permis;
	window.opener.focus();
	window.close();
}

function corporate(no_permis) {
	window.opener.location = 'outfitters.corporate.asp?'+no_permis;
	window.opener.focus();
	window.close();
}

function resizeWindowToImage() {
	var windowWidth,windowHeight;
	windowWidth = document['image'].width;
	windowHeight = document['image'].height;
	var OffH,OffW;
	if (document.all) {
		OffH = document.body.clientHeight;
		OffW = document.body.clientWidth;
	}	else {
		OffW = innerWidth;
		OffH = innerHeight;
	}
	windowWidth = windowWidth-OffW;
	windowHeight = windowHeight-OffH;
	if (windowWidth > screen.availWidth) {
		windowWidth = screen.availWidth;
	}
	if (windowHeight > screen.availHeight) {
		windowHeight = screen.availHeight;
	}
	window.resizeBy(windowWidth,windowHeight);
}

function nextCard(id){
	 switch (id){
		 case 1:
			if (document.form.strCard1.value.length==4) {
				document.form.strCard2.focus();
			}
			break
		 case 2:
			if (document.form.strCard2.value.length==4) {
				document.form.strCard3.focus();
			}
			break
		 case 3:
			if (document.form.strCard3.value.length==4) {
				document.form.strCard4.focus();
			}
			break
	}
}

function checkEmail(email) {
	//var email = document.getElementById('emailaddress');
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		return false;
	}else{
		return true;		
	}
}
