/* -- main navi -- */
function ths(show)
{
	if (document.getElementById(show).style.display=='') 
		document.getElementById(show).style.display = 'none';
	else 
		document.getElementById(show).style.display='';
}

function hs(show)
{
	if (document.getElementById(show).style.display=='')
		document.getElementById(show).style.display = 'none';
	else
	{
		document.getElementById('s1').style.display = 'none';
		document.getElementById('s2').style.display = 'none';
		document.getElementById('s3').style.display = 'none';
		//document.getElementById('s4').style.display = 'none';
		document.getElementById('s5').style.display = 'none';

		document.getElementById(show).style.display = '';
	}
}

function hb(show)
{
	document.getElementById('s1').style.display = 'none';
	document.getElementById('s2').style.display = 'none';
	document.getElementById('s3').style.display = 'none';
	document.getElementById('s4').style.display = 'none';
	document.getElementById('s5').style.display = 'none';
	
	document.getElementById('b1').style.display = 'none';
	document.getElementById('b2').style.display = 'none';
	document.getElementById('b3').style.display = 'none';
	document.getElementById('b4').style.display = 'none';
	document.getElementById('b5').style.display = 'none';
	
	document.getElementById(show).style.display = '';
}

function hss(show)
{
	document.getElementById('ss1').style.display = 'none';
	document.getElementById('ss2').style.display = 'none';
	document.getElementById('ss3').style.display = 'none';
	document.getElementById('ss4').style.display = 'none';
	document.getElementById('ss5').style.display = 'none';
	document.getElementById('ss6').style.display = 'none';
	document.getElementById('ss7').style.display = 'none';
	document.getElementById('ss8').style.display = 'none';	
	
	document.getElementById(show).style.display = '';
}

function ns(show) { document.getElementById('sound').src = show; }

/* -- form helper / -- */

function chckUsername(str)
{
	// between 6 - 12 characters
	if (str.length < 6) return "The login must be at least 6 characters.";
	if (str.length > 12) return "The login must be less than 12 characters long.";
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ( illegalChars.test(str) ) return "The login must contain only characters or numbers. (No spaces)";
	return "NONE";
}

function chckPassword(str1,str2)
{
	// check if match
	if ( str1 != str2) { return "Password mismatch."; }
	// between 6 - 12 characters
	if (str1.length < 6) return "The password must be atleast 6 characters.";
	if (str1.length > 12) return "The password must be less than 12 characters long.";
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ( illegalChars.test(str1) ) return "The password must contain only characters or numbers. (No spaces)";
	return "NONE";
}

/* -- resize blog iframe / -- */
function resize() { document.getElementById('webpiece_blog').height=document.getElementById('webpiece_blog').contentWindow.document.body.scrollHeight; }

/* -- load blog / (must be embedded in iframe) -- */
var ajax;
function loadBlog()
{	
	ajax = new Ajax.Updater(
		'webpiece_blog_div', 
		'blog/index.php', 
		{
			method:'get'
		}
	);
}

function verify_paypal_quick(theform)
{
	var error="NONE";
	// check who
	if(theform.amount.value == "") { error="Please provide the amount you wish to pay." }
	if(!isCurrency(theform.amount)) { error="Please provide the amount you wish to pay in US dollars." }		
	if (error != "NONE") { alert(error); theform.amount.focus(); return; }
	theform.submit();
}

function isCurrency(Field) 
{ 
	strValue = Field.value; 
	regexp = /^(([0-9]{1,3}(\,[0-9]{3})*)|([0-9]{0,3}))(\.[0-9]{2})?$/; 
	return regexp.test(strValue); 
}

