// JavaScript Document

function captcha()
{
	var varChars = $('captcha').value;
	new Ajax.Request('includes/Captcha.php?validate=true&s='+varChars, {
	  method: 'get',
	  onSuccess: function(t) {
		  if(t.responseText == 'SUCCESS') {
				$('captcha_msg').innerHTML = '';
				$('captcha').style.border = '1px solid rgb(221, 221, 221)';
			} else {
				$('captcha_msg').innerHTML = "Please re-type characters.";
			}
	  	}
	});
}

function update_state(){
	new Ajax.Updater('state', 'includes/ajax_update_state.php', {
		asynchronous: false,
		parameters: { country: $('country').value, state: $('state_hidden').value }
	});
	$('state_hidden').value = '';
}

var customerLoginHandler = function(t) {
	
	if(t.responseText == true) {
		new Ajax.Updater('login', 'ajax_custdata.php', {evalScripts: true, onSuccess: custLoginRedirect});
	} else {
		$('login_msg').update('Username/Password incorrect.');
	}
}

var customerLogoutHandler = function(t) {
	new Ajax.Updater('login', 'ajax_custloginform.php', {onSuccess: custLogoutRedirect});
}

var custLoginRedirect = function(t)
{
	
	window.location.href= 'page.php?section=7';	
}

var custLogoutRedirect = function(t)
{	
	window.location.href= 'index.php';	
}
var hideLoginForm = function()
{
	$('loginform').hide();
}
var showLoginForm = function()
{
	$('loginform').show();
}


var parentOn = function(sId) 
{
	var cname = $(sId).className;
	$(sId).className=cname+'on';
}