var isValid = false;
var totalScriptCost = 30;

$('#pmtc_amount').val(totalScriptCost);
$('#pmtmo_amount').val(totalScriptCost);


var id = $("#divTxt").children().size();




var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var phoneReg = /^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}$/;
var isNum =  /^\s*(\+|-)?((\d+(\.\d\d)?)|(\.\d\d))\s*$/;
var isDate = /([1-9]|[1][12])[/]([1-9]|1[1-9]|2[1-9]|3[01])[/]\d\d/;
//var isDate = /(0[1-9]|[12][0-9]|3[01])[- /./](0[1-9]|1[012])[- /./](19|20)\d\d/;

//CHECK TO SEE IF #HASPARTNER HAS BEEN CHECKED

var vsw = false;

$("#havepartner").change(function(){
	
	if( $(this).is(':checked') )
	{
		vsw = true;
		return vsw;
	
	}	
		else
	{
		vsw = false;
		return vsw;
	}
	
	

});




$(function() {
	
	//var isValid = false;
	//var totalScriptCost = 30;
	
	$('.error').hide();
	
	$('label.required').append('&nbsp;<strong>*</strong>&nbsp;');
	$('label.required strong').css({color: 'red', fontWeight: 'bold'});
	  
	
	
	//VALIDATION FOR PAGE 1
	$('#gotoStep2').click(function (e){
		
		$('#pmtc_lastname').val($('#first_lastname').val());
		$('#pmtc_firstname').val($('#first_firstname').val());
	
		$('#pmtmo_lastname').val($('#first_lastname').val());
		$('#pmtmo_firstname').val($('#first_firstname').val());
		
		isValid = false;
		
		validatePage1();
		
		if(isValid){
				$("#step1").hide();
				$("#step2").show();
		}
			
	
	});//END GOTOSTEP2 CLICK EVENT HANDLER
	
	
	//VALIDATION FOR PAGE 2
	$('#gotoStep3').click(function (e){
		isValid = false;
		
		validatePage2();
		
		if(isValid){
				
				$("#step2").hide();
				$("#step3").show();
				
		}
	
	
	});//END GOTOSTEP3 EVENT HANDLER
	
	//VALIDATE LAST PAGE
	$('#submit_btn').click(function(){
	
		validateLastPage();
	
		if(isValid)
		{
			return true;
		}
		
		return false;
		
	});//END SUBMIT HANDLER
	
	
	
	//MAIN PREVIOUS NAVIGATION
	$("#step1, #step2, #step3, #step4, #step5").hide();
	$("#step1").show();
	
	
	
	$("#gotoStep4").click(function () { 
		$("#step3").hide();
		$("#step4").show();
		return false;
    });

	$("#gotoStep5").click(function () { 
		$("#step4").hide();
		//$("#step5").fadeIn("slow");
    });

	//Navigate back
	$("#previous1").click(function () { 
		$("#step1").show();
		$("#step2").hide();
    });
  
	$("#previous2").click(function () { 
		$("#step2").show();
		$("#step3").hide();
    });
	
	$("#previous3").click(function () { 
		$("#step3").show();
		$("#step4").hide();
    });

	$("#previous4").click(function () { 
		$("#step4").show();
		$("#step5").hide();
    });

	

//DISABLE SECOND WRITER INPUT FIELDS
 $('.second-writer :input').attr('disabled', true);
	 $('.second-writer :label').css({color: 'gray'});
	
	$('#havepartner').change(function (){
		
		toggleStatus();
		
	});
	
	function toggleStatus() {
	    if ($('#havepartner').is(':checked')) {
	        $('.second-writer  :input').removeAttr('disabled');
	        $('.second-writer :label').css({color: 'black'});
	        
	    } else {
	    	$('.second-writer :input').attr('disabled', true);
	        $('.second-writer :label').css({color: 'gray'});
	        $('.error').hide();
	        $('.second-writer :input').val('');
	    }   
	}
	
	
//TEXTAREA TEXT CHARACHTER LIMITER	
	
	//Textarea num characters
	var initLimit = 350;
	
	// controls character input/counter
	$('#logline').keyup(function() {
	
	var charLength = $(this).val().length;
	
	//Limit Charachters
	limitText(this, initLimit);

	// Displays count
	$('#remainingChar').html(charLength + ' of 350 characters used');
	
	// Alerts when 350 characters is reached
	if($(this).val().length > initLimit)
	{
		$('#remainingChar').html('<strong>You may only have up to 350 characters.</strong>').addClass("redText");
	}
		else
	{
			$('#remainingChar').removeClass("redText");
	}
	
	
	});
	
	
	
	//AGREEMENT FORM LINKS
	$(".disagree_link").click(function () { 
		alert("To continue with your submission you must agree to the terms of this agreement.")
    });
	
	
//PAYMENT METHOD SELECTBOX
	$(".payment").hide();
	$(".payment:first").fadeIn("slow");
	
	$("#payment_type").change(onSelectChange);  

//PAYEE NAME FIELD TOGGLE
	var check = $('#check_payee');
	var money = $('#money_order_payee');

	$(check, money).hide();
	
	//CHECK PAYEE
	$('.check_cb').change(function (){
		
		toggleCheckPayee();
		
	});
	
	function toggleCheckPayee() {
	    if ($('.check_cb').is(':checked')) {
	       
	       $('#check_payee').show();
	        
	    } else {
	  	
	  		$('#check_payee').hide();
	  	
	  	}   
	}
	
	//MONEY ORDER PAYEE
	$('.money_cb').change(function (){
		
		toggleMoneyPayee();
		
	});
	
	function toggleMoneyPayee() {
	    if ($('.money_cb').is(':checked')) {
	       
	       $('#money_order_payee').show();
	        
	    } else {
	  	
	  		$('#money_order_payee').hide();
	  	
	  	}   
	}

//SET WRITERS NAME PREPOPULATE
	var wln = $('#first_lastname').val();
	var wfn = $('#first_firstname').val();
	
	//CHECK
	$('#pmtc_lastname').val(wln);
	$('#pmtc_firstname').val(wfn);
	
	//MONEY
	$('#pmtmo_lastname').val(wln);
	$('#pmtmo_firstname').val(wfn);

	
	
	

});//END OF $FUNCTION



/****************/
//// FUNCTIONS ///
/****************/

////VALIDATE PAGE 1
function validatePage1(){

//VALIDATE FIRST WRITER"S FIELDS
		
		// validate and process form here
		$('.error').hide();

		//Validate Last Name
		var first_lastname = $("input#first_lastname").val();  
		if (first_lastname == "") {  
			$("#first_lastname_error").show();  
			$("input#first_lastname").focus();  
	    	
	    	return false; 
		}	
			else
		{
			$("#first_lastname_error").hide(); 
		}
		
		//Validate Last Name
		var first_firstname = $("input#first_firstname").val();  
		if (first_firstname == "") {  
			$("#first_firstname_error").show();
			$("input#first_firstname").focus(); 
			 
	    	return false;   
		}
			else
		{
			$("#first_firstname_error").hide();
		}
		
		//Validate Secondary Address
		var first_address = $("input#first_address").val();  
		if (first_address == "") {  
			$("#first_address_error").show();
			$("input#first_address").focus();  
	    	
	    	return false;  
		}
			else
		{
			$("#first_address_error").hide();
		}
				
		//Validate City
		var first_city = $("input#first_city").val();  
		if (first_city == "") {  
			$("#first_city_error").show();
			$("input#first_city").focus();  
	    	
	    	return false;  
		}	
			else
		{
			$("#first_city_error").hide();
		}	
		
		//Validate state
		var first_state = $("select#first_state").val();  

		if (first_state == "") {  
			$("#first_state_error").show();
			$("input#first_state").focus();  
	    	
	    	return false;  
		}
			else
		{
			$("#first_state_error").hide();
		}
		
		//Validate zipcode
		var first_zip = $("input#first_zip").val();  

		if (first_zip == "") {  
			$("#first_zip_error").show();
			$("input#first_zip").focus();  
	    	
	    	return false;  
		}
			else
		{
			$("#first_zip_error").hide();
		}
		
		
		//Validate Phone
		var phone = $("input#first_phone").val();
		if (phone == "") {  
			$("#first_phone_error").show();  
			$("input#phone").focus();  
			 
			return false;  
		} 	
			else if(!phoneReg.test(phone)) 
		{
			$("#first_phone_error2").show();  
			$("input#phone").focus();  
			
			return false;  
		}
			else
		{
			$("#first_phone_error2").hide(); 
		}

				
		//Validate Email
		var first_email = $("input#first_email").val();
		
		if (first_email == "") {  
			$("#first_email_error").show();  
			$("input#first_email").focus(); 
			 
			return false;   
		} 
			else if(!emailReg.test(first_email)) 
		{
			$("#first_email_error").hide();  
			$("#first_email_error2").show();  
			$("input#first_email").focus(); 
			 
			return false; 
		}
			else
		{
			$("#first_email_error2").hide();
		}
		
		//Validate Email Varified
		var first_varify_email = $("input#first_varify_email").val();
		
		if (first_varify_email == "") {  
			$("#first_varify_email_error").show();  
			$("input#first_varify_email").focus();
			  
			return false;  
		} 
			else if(!emailReg.test(first_varify_email)) 
		{
			$("#first_varify_email_error1").show();  
			$("input#first_varify_email").focus(); 
			 
			return false;
		} 
			else if(first_varify_email != first_email)
		{
			$("#first_varify_email_error1").hide();  
			$("#first_varify_email_error2").show();  
			$("input#email_varify").focus();
			
			return false;
		} 
			else
		{
			$("#first_varify_email_error2").hide();  
		}


		
		if(vsw)
		{
			
			validateSecondWriter();
			
		} 
			else
		{
			
			isValid = true;
			return isValid;
		}

}



//VALIDATE SECOND WRITER"S FIELDS
function validateSecondWriter()
{
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var phoneReg = /^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}$/;
	var isNum =  /^\s*(\+|-)?((\d+(\.\d\d)?)|(\.\d\d))\s*$/;
	var isDate = /(0[1-9]|[12][0-9]|3[01])[- /./](0[1-9]|1[012])[- /./](19|20)\d\d/;
	
	//Validate Last Name
	var second_lastname = $("input#second_lastname").val();  
	if (second_lastname == "") {  
		$("#second_lastname_error").show().css({color: 'red'});  
		$("input#second_lastname").focus();  
    	
    	return false; 
	}

	//Validate Second First Name
	var second_firstname = $("input#second_firstname").val();  
	if (second_firstname == "") {  
		$("#second_firstname_error").show().css({color: 'red'});  
		$("input#second_firstname").focus();  
    	
    	return false; 
	}	
	
				
	//Validate Secondary Address
	var second_address = $("input#second_address").val();  
	if (second_address == "") {  
		$("#second_address_error").show();
		$("#second_address_error").css({color: "red"});
		$("input#second_address").focus();  
    	
    	return false;  
	}
	
				
	//Validate City
	var second_city = $("input#second_city").val();  
	if (second_city == "") {  
		$("#second_city_error").show();
		$("#second_city_error").css({color: "red"});
		$("input#second_city").focus();  
    	
    	return false;  
	}
					
	
	//Validate state
	var second_state = $("select#second_state").val();  

	if (second_state == "") {  
		$("#second_state_error").show();
		$("#second_state_error").css({color: "red"});
		$("input#second_state").focus();  
    	
    	return false;  
	}
		
	
	//Validate zipcode
	var second_zip = $("input#second_zip").val();  

	if (second_zip == "") {  
		$("#second_zip_error").show();
		$("#second_zip_error").css({color: "red"});
		$("input#second_zip").focus();  
    	
    	return false;  
	}
	
	//Validate Phone
	var second_phone = $("input#second_phone").val();
	if (second_phone == "") {  
		$("#second_phone_error").show();
		$("#second_phone_error").css({color: "red"});  
		$("input#second_phone").focus();  
		 
		return false;  
	} 	
		else if(!phoneReg.test(second_phone)) 
	{
		$("#second_phone_error2").show();
		$("#second_phone_error2").css({color: "red"});    
		$("input#phone").focus();  
		
		return false;
		return false;   
	}
		
			
	//Validate Email
	var second_email = $("input#second_email").val();
	if (second_email == "") {  
		$("#second_email_error").show(); 
		$("#second_email_error").css({color: "red"});   
		$("input#second_email").focus();  
		
		return false;   
	} 
		else if(!emailReg.test(second_email)) 
	{
		$("#second_email_error2").show();
		$("#second_email_error2").css({color: "red"});    
		$("input#second_email").focus();  
		
		return false; 
	}
	
	
	//Validate Email Varified
	var email_varify2 = $("input#second_varified_email").val();
	
	if (email_varify2 == "") {  
		$("#second_varified_email_error").show();
		$("#second_varified_email_error").css({color: "red"});    
		$("input#second_varified_email").focus();  
		 
		return false;  
	} 
		else if(!emailReg.test(email_varify2)) 
	{
		$("#second_varified_email_error1").show();
		$("#second_varified_email_error1").css({color: "red"});   
		$("input#second_varified_email").focus();  
		 
		return false;
	} 
		else if(second_email != email_varify2)
	{
		$("#second_varified_email_error2").show();
		$("#second_varified_email_error2").css({color: "red"});  
		$("input#second_varified_email").focus(); 
		
		return false;
	}
		else
	{
		isValid = true;
		return isValid;
	}

	
	
	
}//End validateSecondWriter Function
	
	
function validatePage2()
{
	
	//Validate state
			var genre = $("select#genre").val();  
			if (genre == "") {  
				$("#genre_error").show();
				$("#genre_error").css({color: "red"});
				$("input#genre").focus();  
		    	
		    	return false;  
			}
				else
			{
				$("#genre_error").hide();
			}			
			
			
			
			//Validate Sieries Title
			var series_title = $("input#series_title").val();  
	
			if (series_title == "") {  
				$("#series_title_error").show();
				$("#series_title_error").css({color: "red"});
				$("input#series_title").focus();  
		    	
		    	return false;  
			}
				else
			{
				$("#series_title_error").hide();
			}
			
			
			//Validate Episode Title
			var episode_title = $("input#episode_title").val();  
	
			if (episode_title == "") {  
				$("#episode_title_error").show();
				$("#episode_title_error").css({color: "red"});
				$("input#episode_title").focus();  
		    	
		    	return false;  
			}
				else
			{
				$("#episode_title_error").hide();
			}
			
			//Validate Script LogLine
			var logline = $("#logline").val();  
			
			if(logline == "") {  
				$("#logline_error").show();
				$("#logline_error").css({color: "red"});
				$("#logline").focus();
				
		    	return false;  
			}
				else
			{
				$("#logline_error").hide();
				
				if($("#divTxt").children().size() == 0)
				{
					
					isValid = true;
					return isValid;
									
				}
					else
				{
					validateDivTxtChildren();
				}
			}
			
			return false;

}//END VALIDATION PAGE 2	
	
	
//VALIDATE DIVTXT
function validateDivTxtChildren()
{	
	var id = $("#divTxt").children().size();
	
	//Genre
	if( $('#genre' + id).val() == "" )
	{
		$('#genre' + id + "_error").show();
		return false;
	}
		else
	{
		$('#genre' + id + "_error").hide();
	}
	
	//Series Title
	if( $('#seriestitle' + id).val() == "" )
	{
		$('#seriestitle' + id + "_error").show();
		return false;
	}
		else
	{
		$('#seriestitle' + id + "_error").hide();
	}
	
	
	//Episode Title
	if( $('#episodetitle' + id).val() == "" )
	{
		$('#episodetitle' + id + "_error").show();
		return false;
	}
		else
	{
		$('#episodetitle' + id + "_error").hide();
	}
	
	
	//Longline
	if( $('#logline' + id).val() == "" )
	{
		$('#logline' + id + "_error").show();
		return false;
	}
		else
	{
		$('#logline' + id + "_error").hide();
		$("#step2").hide();
		$("#step3").show();
	}
	
}

	
	
	
//LAST PAGE VALIDATION
function validateLastPage()
{
	isValid = false;
	switch( $('#payment_type option:selected').text() )
			{
				case 'By Check':
					
					//Validate Payment Last Name
					var pmtc_lastname = $("input#pmtc_lastname").val();  
			
					if (pmtc_lastname == "") {  
						$("#pmtc_lastname_error").show();
						$("#pmtc_lastname_error").css({color: "red"});
						$("input#pmtc_lastname").focus();  
						
				    	return false;  
					}
						else
					{
					
						$("#pmtc_lastname_error").hide();
					}
					
					//Validate Payment First Name
					var pmtc_firstname = $("input#pmtc_firstname").val();  
			
					if (pmtc_firstname == "") {  
						$("#pmtc_firstname_error").show();
						$("#pmtc_firstname_error").css({color: "red"});
						$("input#pmtc_firstname").focus();  
				    	
				    	return false;  
					}
						else
					{
						$("#pmtc_firstname_error").hide();
					}
					
					//Validate Payment Amount
					var pmtc_amount = $("input#pmtc_amount").val();  
					
					if (pmtc_amount == "") {  
						$("#pmtc_amount_error").show();
						$("#pmtc_amount_error").css({color: "red"});
						$("input#pmtc_amount").focus();  
				    	
				    	return false;  
					}
						else
					{
						$("#pmtc_amount_error").hide();
					}
						
					
					//Validate Payment Check Number
					var pmtc_amount = $("input#pmtc_check_number").val();  
			
					if (pmtc_amount == "") {  
						$("#pmtc_check_number_error").show();
						$("#pmtc_check_number_error").css({color: "red"});
						$("input#pmtc_check_number").focus();  
				    	
				    	return false;  
					}
						else
					{
						$("#pmtc_check_number_error").hide();
					}
					
					//Validate Payment Bank Name
					var pmtc_bank_name = $("input#pmtc_bank_name").val();  
			
					if (pmtc_bank_name == "") {  
						$("#pmtc_bank_name_error").show();
						$("#pmtc_bank_name_error").css({color: "red"});
						$("input#pmtc_bank_name").focus();
				    	
				    	return false;  
					}
						else
					{
						$("#pmtc_bank_name_error").hide();
					}
					
					//Validate Payment Check Date
					var pmtc_check_date = $("input#pmtc_check_date").val();  
			
					if (pmtc_check_date == "") {  
						$("#pmtc_check_date_error").show();
						$("#pmtc_check_date_error").css({color: "red"});
						$("input#pmtc_check_date").focus();  
						
				    	return false;  
					}
						else if(!isDate.test(pmtc_check_date)) 
					{
						$("#pmtc_check_date_error").hide(); 
						$("#pmtc_check_date_error2").show();  
						$("input#pmtc_check_date").focus();  
						
						return false;
					}	
						else
					{
						isValid = true;
						return isValid;
					}
					
				break;
				
				case 'By Money Order':
					
					//Validate Payment Last Name
					var pmtmo_lastname = $("input#pmtmo_lastname").val();  
			
					if (pmtmo_lastname == "") {  
						$("#pmtmo_lastname_error").show();
						$("#pmtmo_lastname_error").css({color: "red"});
						$("input#pmtmo_lastname").focus();  
				    	
				    	return false;  
					}
						else
					{
					
						$("#pmtmo_lastname_error").hide();
					}
					
					//Validate Payment First Name
					var pmtmo_firstname = $("input#pmtmo_firstname").val();  
			
					if (pmtmo_firstname == "") {  
						$("#pmtmo_firstname_error").show();
						$("#pmtmo_firstname_error").css({color: "red"});
						$("input#pmtmo_firstname").focus();  
				    	
				    	return false;  
					}
						else
					{
						$("#pmtmo_firstname_error").hide();
					}
					
					//Validate Payment Amount
					var pmtmo_amount = $("input#pmtmo_amount").val();  
					
					if(pmtmo_amount == "") {  
						$("#pmtmo_amount_error").show();
						$("#pmtmo_amount_error").css({color: "red"});
						$("input#pmtmo_amount").focus();  
				    	
				    	return false; 
				 
					}
						else
					{
						$("#pmtmo_amount_error").hide();
						
					}
						
					
					//Validate Payment Check Number
					var pmtmo_money_order_number = $("input#pmtmo_money_order_number").val();  
			
					if (pmtmo_money_order_number == "") {  
						$("#pmtmo_money_order_number_error").show();
						$("#pmtmo_money_order_number_error").css({color: "red"});
						$("input#pmtmo_money_order_number").focus();  
				    	
				    	return false;  
					}
						else
					{
						$("#pmtmo_money_order_number_error").hide();
					}
					
					//Validate Payment Bank Name
					var pmtmo_place_of_purchase = $("input#pmtmo_place_of_purchase").val();  
			
					if (pmtmo_place_of_purchase == "") {  
						$("#pmtmo_place_of_purchase_error").show();
						$("#pmtmo_place_of_purchase_error").css({color: "red"});
						$("input#pmtmo_place_of_purchase_name").focus();
				    	
				    	return false;  
					}
						else
					{
						$("#pmtmo_place_of_purchase_error").hide();
					}
					
					//Validate Payment Check Date
					var pmtmo_money_order_dated = $("input#pmtmo_money_order_dated").val();  
			
					if (pmtmo_money_order_dated == "") {  
						$("#pmtmo_money_order_dated_error").show();
						$("#pmtmo_money_order_dated_error").css({color: "red"});
						$("input#pmtmo_money_order_dated_date").focus();  
				    	return false;  
					}
						else if(!isDate.test(pmtmo_money_order_dated)) 
					{
						$("#pmtmo_money_order_dated_error").hide(); 
						$("#pmtmo_money_order_dated_error2").show();  
						$("input#pmtmo_money_order_dated").focus();  
						
						return false;
					} 
						else
					{
						isValid = true;
						return isValid;
					}				
			
										
				break;

			}//CHECK WHICH SELECTION WAS SELECTED (CHECK OR MONEY ORDER);
			
					
}//END LAST PAGE VALIDATION



//LIMIT TEXT FUNCTION
		function limitText(limitField, limitNum) {
			if (limitField.value.length > limitNum + 2) {
				limitField.value = limitField.value.substring(0, limitNum);
			}
		}

//PAYMENT SELECT DROPDOWN FUNCTION
		function onSelectChange() {
			var check = $('#check_payee');
			var money = $('#money_order_payee');
	 
			var selected = $("#payment_type option:selected");       
			var output = "";  
			//alert(selected.val());
		
			if(selected.val() == "check"){  
				$("#check").fadeIn("slow");
				$("#moneyorder").hide();
				$("#paypal").hide();
				$(check).hide(); 
			}  
			
			if(selected.val() == "moneyorder"){  
				$("#moneyorder").fadeIn("slow");
				$("#check").hide();
				$("#paypal").hide();
				$(money).hide(); 
			}
			
			if(selected.val() == "paypal"){  
				//navToPayPal();
				$("#paypal").fadeIn("slow");
				$("#check").hide();
				$("#moneyorder").hide();
			}
		}


//ADD/REMOVE FUNCTION
function addFormField() {
		
	var id = $("#divTxt").children().size();
	var currentID = id + 1;
		
	//Form Elements To Add
		var $divStart = "<div id=\'scriptInfo" + currentID + " ' " + ">";
		var $divEnd =  "</div>";
		
		var $divContent = "<p id='row" + currentID + "'>" +
						  "<label for='genre" + currentID + "'>Select Genre:</label>" +
						  "<select name='genre" + currentID + "'" +  "id=\'genre" + currentID +  "'>" +
	  					  "<option value=\"\">Please select gener</option>" +
	  					  "<option value='comedy'>Comedy</option>" +
	  					  "<option value='drama'>Drama</option>" +
						  "</select>" +
						  "<span class=\'error\' id=\'genre" + currentID + "_error'" + ">Please enter a genre.</span>" +
						  "<br />" +
						  "<label for='seriestitle" + currentID + "'>Series Title:</label>" +
						  "<input type='text' name='seriestitle" + currentID + "'" + "value=\'\'" + "id='seriestitle" + currentID + "'" + "/>" +
						 "<span class=\'error\' id=\'seriestitle" + currentID + "_error'" + ">Please enter a series title.</span>" +
						  "<br />" +
						  "<label  for='episodetitle" + currentID + " ' " + ">Episode Title:</label>" +
						  "<input type='text' name='episodetitle" + currentID +"'" + "value=\'\'" + "id='episodetitle" + currentID + "'" + "/>" +
						  "<span class=\'error\' id=\'episodetitle" + currentID + "_error'" + ">Please enter a series title.</span>" +
						  "<br />" +
						  "<label for='logline'>Script Logline</label><br />" +
						  "<textarea name='logline" + currentID +"'" + "value=\'\'" + "id='logline" + currentID + "'" + "rows=\'2\' col=\'20\' " + ">" + "</textarea>" + 
						  "<span class=\'error\' id=\'logline" + currentID + "_error'" + ">Please enter a series title.</span>" +
						  "<br /><br />" +
						  "<a href='#' class=\"remove\"); return false;'>Remove</a>" +
						  "</p>";
		
		var $toAdd = $divStart + $divContent + $divEnd;

		$("#divTxt").append($toAdd);
	
		$("#row" + currentID).highlightFade({
			speed:1000
		});	
		
		totalScriptCost = 30 * (currentID + 1);	
		setAmountTotal(totalScriptCost);
		//alert(totalScriptCost);
		
		$(".error").hide();
}

//Remove Fields
$('a.remove').live("click", function(){

	$(this).parent().parent().remove();
	totalScriptCost = totalScriptCost - 30;
	setAmountTotal(totalScriptCost);
	
});


function setAmountTotal(t)
{
	$('#pmtc_amount').val(t);
	$('#pmtmo_amount').val(t);
	
}


//Print Terms and Conditions
$('#print a').click(function() {
		
		// Print the DIV.
		$( ".printable" ).print();
 		
 		// Cancel click event.
		return( false );
							
});
