

/*******************************  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').slideDown('fast');
  });
  
  $('input#renewINT').click(function() {
 		$('#haveCode').slideDown('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() {	
	var errors = 0;
	var requiredFields=new Array("Text1","Text2","Text5","Text7","State","Text8","Text4","Text3","custom12","custom16","Text9","Text10","Select2","Select3","element_14");  // Form element IDs
	requiredFields = requiredFields.reverse(); // Reverse to put focus on top-most element
	for(var i in requiredFields) {
		if (isBlank(document.getElementById(requiredFields[i]).value)) {
			document.getElementById(requiredFields[i]).focus();
			document.getElementById(requiredFields[i]).style.border = '2px solid #FF0000';
			errors++;
		} else {
			document.getElementById(requiredFields[i]).style.border = '1px solid #7C7C7C #C3C3C3 #DDDDDD';
		}
	}
	if (errors == 0) {
		document.getElementById('submitButton').style.display = 'none';
		document.getElementById('submitProcessing').style.display = 'block';
	} else {
		alert('Please correct the required field(s) highlighted in red.');
		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);
}
