// JavaScript Document
$(document).ready(
	function(){
	$("#joinSubmit").click( 
		function () {
				//alert($("#upd_email").attr("value"));
				var qName = $("#upd_name").attr("value");
				var qEmail = $("#upd_email").attr("value");
				
				if (qName != "name" && qEmail != "Email Address")
				{
					$("#imgLoader").attr("class","dspOn");
					$("#updateMeDiv").hide("slow",
					function () {
						$.ajax({
							type: "POST",
							url: "index.php?pr=general.getUpdates&nodesign=true",
							//dataType: "text",
							data: "upd_name=" + qName + "&upd_email=" + qEmail,
							success: 
							  function(msg)
								{
									$("#updateMeDiv").html(msg);
									$("#updateMeDiv").show("slow");
								},
							complete: function(){ $("#imgLoader").attr("class","dspOff"); }
						});
				});
				} else {
					alert('Please enter a name and email address');
				}
		}
	);
});

function imgNext(fOrB) {
	
	$("#imgLoader").attr("class","dspOn");
	
	linkID		= "#imgNext";
	if (fOrB != 1)
		linkID	= "#imgPrev";

	var pr		= $(linkID).attr("pr");
	var pg		= $(linkID).attr("pg");
	//var pr			= 'gallery.commercial';
	//var pg			= 4;
	
	//$("#main").load('index.php?nodesign=1&pr=' + pr + '&pg=' + pg,'',alert('done'));

	$.ajax({
		type: "GET",
		url: "index.php?nodesign=true&pr=" + pr + "&pg=" + pg,
		success: function(html){ $("#main").html(html); },
		complete: function(){ $("#imgLoader").attr("class","dspOff"); }
	});
}





function dspMsg(msg,idVal)
{
	document.getElementById('form-message').display = 'block';
	document.getElementById('form-message').innerHTML = msg;
	if (idVal) { highF(idVal,1); }
}

function highF(idVal,onOff)
{
	if (onOff == 1)
	{
		idVal.style.border = '1px solid #ff0000';
	} else {
		idVal.style.border = '0px solid #ff0000';
	}
}

function formSubmit(formName)
{
	document.getElementById(formName).submit();
}

function jumpToURL(url)
{
	document.location = url;
}

function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function imgWidth(img,widthToBe)
{
	currWidth	= document.getElementById(img).width;
	if (currWidth > widthToBe)
	{
		document.getElementById(img).width = widthToBe;
	}	
}

function hideShow(id,fromID)
{
	if (document.getElementById(id).style.display == 'none')
	{
		document.getElementById(id).style.display		= 'block';
		document.getElementById(fromID).innerHTML		= '-';
	} else {
		document.getElementById(id).style.display		= 'none';
		document.getElementById(fromID).innerHTML		= '+';
	}
}

function siteSearch(sq)
{
	loc = '/nmd/general/search/?from=home&sq=' + sq;
	document.location = loc;
}

function subForm(e,v)
{
	var k;
	if(window.event) // IE
	{
		k = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		k = e.which;
	}

	if (k == 13)
		siteSearch(v);

}

function resizeStuff(){
	
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	
	if (viewportheight < 600)
		viewportheight = 600;
	
	viewportheight			= viewportheight - 20;//20px is the height of the bar
	divFooter				= document.getElementById('footer');
	divFooter.style.top		= viewportheight + 'px';


	//resize outer menu
	//var div1				= document.getElementById('menuSub');	//div to resize
	//var div2				= document.getElementById('main');		//div to get size from
	//div1.style.height		= div2.offsetHeight+"px";
	//div1.style.minHeight	= div2.offsetHeight+"px";
	//div1.style.visibility	= 'visible';
}

function fontSizer(level){
	if (level == 0.58)
	{
		fontToBe		= '11px';
	} else if (level == 0.75)
	{
		fontToBe		= '13px';
	} else {
		fontToBe		= '15px';
	}
	//resize the font
	document.getElementById('main').style.fontSize			= fontToBe;
	//readjust menu size
	resizeStuff();

	//save change
	document.getElementById('savingLoad').style.display		= "block";
	ExecuteAjax('?pr=general.act_saveSettings&fontSize=' + fontToBe,'savingLoad');
	
	
}