

/*******************************  Show/Hide Layers   ******************************************/


$(document).ready(function() {
  $('#haveCode').hide();
  $('input#newUS').click(function() {
 		$('#haveCode').slideDown('fast');
  });
  $('input#newINT').click(function() {
 		$('#haveCode').slideDown('fast');
  });
  
  $('input#renewUS').click(function() {
 		$('#haveCode').slideUp('fast');
  });
  
  $('input#renewINT').click(function() {
 		$('#haveCode').slideUp('fast');
  });
});



$(document).ready(function() {
   $('#useBilling').hide();
  $('input#Checkbox1').click(function() {
 		$('#useBilling').toggle('normal');
  });
  
});

$(document).ready(function() {
   $('#note').hide();
  $('input#Text1').click(function() {
 		$('#note').slideDown('normal');
  });
  
});



/*******************************  Testimoials Slideshow  ******************************************/

$(function() {
		   
	$.fn.cycle.defaults = { 
    timeout:       10000,  // milliseconds between slide transitions (0 to disable auto advance) 
    speed:         1000,  // speed of the transition (any valid fx speed value) 
    next:          null,  // id of element to use as click trigger for next slide 
    prev:          null,  // id of element to use as click trigger for previous slide 
    before:        null,  // transition callback (scope set to element to be shown) 
    after:         null,  // transition callback (scope set to element that was shown) 
    height:       'auto', // container height 
    sync:          1,     // true if in/out transitions should occur simultaneously 
    fit:           0,     // force slides to fit container 
    pause:         0,     // true to enable "pause on hover" 
    delay:         0,     // additional delay (in ms) for first transition (hint: can be negative) 
    slideExpr:     null,  // expression for selecting slides (if something other than all children is required) 
};


    $('#testimonials').cycle();
    
});

/*******************************  Form Script   ******************************************/

//only submit the form once
var submitcount=0;

function CodeLookup() {
	//look up the new source code, don't submit the form for processing
	Form1.SubmitForm.value = 0;
	Form1.submit();
}

function ccAddress() {
	//collect the billing address, don't submit the form for processing
	Form1.SubmitForm.value = 0;
	if (Form1.chkUseShippingAddress.checked == true) {
		Form1.ccUseShippingAddress.value = 1;		
	} else {
		Form1.ccUseShippingAddress.value = 0;
	}
	Form1.submit();
}

function UpdateState() {
	//copy state info
	if (Form1.StateOptions.selectedIndex != 0) {
		Form1.State.value = Form1.StateOptions.value;
		Form1.StateOptions.selectedIndex = 0;
	}
	//Form1.submit();
}


function FormSubmit() {	
alert('Please Enter Your First Name');
	if (Form1.SubmitForm.value == 1) {
		//check that all necessary values are entered
		if (isBlank(Form1.FirstName.value)) {
			alert('Please Enter Your First Name');
			Form1.FirstName.focus();
			Form1.FirstName.value = '';
			return false;
		}
		if (isBlank(Form1.LastName.value)) {
			alert('Please Enter Your Last Name');
			Form1.LastName.focus();
			Form1.LastName.value = '';
			return false;
		}
		if (isBlank(Form1.Email.value)) {
			alert('Please Enter Your Email Address');
			Form1.Email.focus();
			Form1.Email.value = '';
			return false;
		}
		if (isBlank(Form1.Address1.value)) {
			alert('Please Enter Your Address');
			Form1.Address1.focus();
			Form1.Address1.value = '';
			return false;
		}
		if (isBlank(Form1.City.value)) {
			alert('Please Enter Your City');
			Form1.City.focus();
			Form1.City.value = '';
			return false;
		}
		if (isBlank(Form1.State.value)) {
			alert('Please Select Your State');
			Form1.State.focus();
			return false;
		}
		if (isBlank(Form1.Zip.value)) {
			alert('Please Enter Your Zip Code');
			Form1.Zip.focus();
			Form1.Zip.value = '';
			return false;
		}
		if (isBlank(Form1.ccName.value)) {
			alert('Please Enter Your Name As It Appears On Your Credit Card');
			Form1.ccName.focus();
			Form1.ccName.value = '';
			return false;
		}
		if (isBlank(Form1.ccNumber.value)) {
			alert('A Credit Card Number Is Required');
			Form1.ccNumber.focus();
			Form1.ccNumber.value = '';
			return false;
		}
		if (isBlank(Form1.CVV.value)) {
			alert('A Credit Card Verification Value (CVV) Is Required');
			Form1.CVV.focus();
			Form1.CVV.value = '';
			return false;
		}
		//only check billing address if necessary
		if (!Form1.chkUseShippingAddress.checked) {
			if (isBlank(Form1.ccAddress1.value)) {
				alert('Please Enter Your Billing Address');
				Form1.ccAddress1.focus();
				Form1.ccAddress1.value = '';
				return false;
			}
			if (isBlank(Form1.ccCity.value)) {
				alert('Please Enter Your Billing City');
				Form1.ccCity.focus();
				Form1.ccCity.value = '';
				return false;
			}
			if (Form1.ccState.selectedIndex == 0) {
				alert('Please Select Your Billing State');
				Form1.ccState.focus();
				return false;
			}
			if (isBlank(Form1.ccZip.value)) {
				alert('Please Enter Your Billing Zip Code');
				Form1.ccZip.focus();
				Form1.ccZip.value = '';
				return false;
			}
		}
		//everything checks out OK, submit the form (if the button hasn't already been clicked)
		if (submitcount == 0) {
			submitcount++;
			Form1.SubmitForm.value = 1;
			Form1.submit();				
		}
	}
	return false;
}

function isBlank(val){
	if (val==null) {
		return true;
	}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")) {
			return false;
		}
	}
	return true;
}

/*******************************  Rounded Corners   ******************************************/
   
   $(document).ready(function(){
    	$('#testimonials').corner();
		$('#haveCode').corner("20");
		$('#useBilling').corner();
		$('#subscriberIDBox').corner();
		$('#note').corner();
		$('#message').corner();
    });
   
   
/*******************************  Open New Window   ******************************************/   
   
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}