
function initForm(){
	//$('part3').toggle();
	totals = $$('div#form .item');
	for(var i=0; i<totals.length; i++){
		totals[i].addClassName('opacity');
	}
	$('part1').addClassName('fullVisibility');
	$('tenmonth').show();
	$('banner_code').disable();
	$('statesDiv').hide();
	$('mysplatNum').disable();
}

function toggle23( a ){
	switch(a){
		case 2:
			$('part2').show();
			//$('part3').hide();
			break;
		case 3:
			$('part2').hide();
			//$('part3').show();
			break;
		default:
			break;
	}
}

function doToggle(active, deActive){
	$(active).show();
	$(deActive).hide();
}

function focused(a){
	switch(a){
		case 2:
			//if( $('zipMonth').value != '' )
			$('part2').addClassName('fullVisibility');
			break;
		case 3:
			$('part3').addClassName('fullVisibility');
			break;
		case 5:
			$('part5').addClassName('fullVisibility');
			break;
		default:
			break;
	}
}

function showOptions(a){
	switch(a){
		case 10:
			$('tenmonth').show();
			$('tenmonth').style.background = 'url(images/check.gif) center left no-repeat ';
			$('tenmonth').style.backgroundColor = '#DFFB77';
			$('tenmonth').style.color = '#000000';
			break;
		default:
			break;
	}
}

function hideOptions(a){
	switch(a){
		case 10:
			$('tenmonth').show();
			$('tenmonth').style.background = 'none';
			$('tenmonth').style.backgroundColor = 'none';
			$('tenmonth').style.color = '#FFFFFF';
			break;
		default:
			break;
	}
}

function focusBannerCode(fieldElement, defaultTxt){
	if( fieldElement.value == defaultTxt ){
		fieldElement.value = '';
	}
	
}

function blurBannerCode(fieldElement, defaultTxt){
	if( fieldElement.value == '' )
		fieldElement.value = defaultTxt;
		
	if( fieldElement.value != defaultTxt )
		$('part4').addClassName('fullVisibility');
	else
		$('part4').removeClassName('fullVisibility');
}

function focusDIV(a,l){
	if( a.className != 'fullVisibility'){
		a.addClassName('partVisibility');
		$(l).addClassName('partVisibility');
	}
}

function blurDIV(a,l){
	if( a.className != 'fullVisibility'){
		a.removeClassName('partVisibility');
		$(l).removeClassName('partVisibility');
	}
}
function checkforVisibility(){
	elements = $$('.required');
	ok=true;
	for( i=0;i<elements.length;i++){
		if(elements[i].value == '')
			ok = false;
	}
	if( ok == true){
		$('part6').addClassName( 'fullVisibility' );
	} else {
		$('part6').removeClassName( 'fullVisibility' );
	}
}


function doDiscountVisibility(){
	
	if( $('bannerPercent').checked == true ||  $('disPercent').checked == true){
		$('part4').addClassName( 'fullVisibility' );
	} else {
		$('part4').removeClassName( 'fullVisibility' );
	}
/**/
}

function getPrice()
{
	var url = 'calculate.php';
	var pars = Form.serialize('form');
//	alert(pars);
	var myAjax = new Ajax.Updater(
		'totalAmount',
		url,
		{
		method: 'get',
		parameters: pars
	});

}

function checkForSubmission(){
	return true;
}

function doEnable(status, elementId){
	switch(status){
		case true:
			$(elementId).enable();
			break;
		case false:
			$(elementId).disable();
			break;
		default:
			break;
	}
}

function doEnable2(){
	var enable = false;
	for( var i=1 ; i<arguments.length ; i++){
		if( $(arguments[i]).checked == true) {
			$(arguments[0]).enable();
			enable = true;
			break;
		}
	}
	if( !enable ){ 
		$(arguments[0]).disable();
	}
}

function openWinow(url){
	newwindow=window.open(url,'Find Zip Code','width=400,height=200,left=0,top=100,screenX=0,screenY=100');
	if (window.focus) {newwindow.focus()}
}

function ValidateNumber(value,elementId){
	//if(value.test('/'))
	if(value != '' && isNaN(value) ){
		$(elementId).innerHTML = 'Only numbers are allowed';
		$('part2').removeClassName('fullVisibility');
		$('zipMonth').value = '';
	}
	else{
		if( value < 3 ){
			$(elementId).innerHTML = 'Minimum three months required';
			$('part2').removeClassName('fullVisibility');
		} else {
			$(elementId).innerHTML = '';
			$('part2').addClassName('fullVisibility');
			getPrice();
		}
	}
}

function selectText(status,element){
	
	switch(status){
		case true:
			$(element).value = '<a href="http://www.msplinks.com/MDFodHRwOi8vd3d3Lm15c3BsYXQuY29t" id="banner_code"><img src="http://www.mysplat.com/myspace/banner1.gif" alt="mySplat Paintball Community"></a>';
        	$(element).select();
			break;
		case false:
			//$(element).value = element.value;
			break;
		default:
			break;
	}
}

function SubmitForm(){

	var url = 'mail.php';
	var pars = Form.serialize('form');
	var myAjax = new Ajax.Updater(
		'submitResult',
		url,
		{
		method: 'post',
		parameters: pars
	});

}