function resizeTxt(action){ 
	var plusSize = $("#mid_con").css("font-size");
	var minusSize = $("#mid_con").css("font-size"); // the same value but fixes an IE error with switch statement
	if(action == "minus"){
		switch(minusSize){
			case "10px":
				$("#mid_con").css("font-size", "10px");
				$("h2").css("font-size", "11px");
				break;
			case "12px":
				$("#mid_con").css("font-size", "10px");
				$("h2").css("font-size", "12px");
				break;
			case "13px":
				$("#mid_con").css("font-size", "12px");
				$("h2").css("font-size", "15px");
				break;
			case "14px":
				$("#mid_con").css("font-size", "13px");
				$("h2").css("font-size", "16px");
				break;
			case "16px":
				$("#mid_con").css("font-size", "14px");
				$("h2").css("font-size", "18px");
				break;
			case "18px":
				$("#mid_con").css("font-size", "16px");
				$("h2").css("font-size", "20px");
				break;
			case "20px":
				$("#mid_con").css("font-size", "18px");
				$("h2").css("font-size", "22px");
				break;
			default:
				$("#mid_con").css("font-size", "13px");
				$("h2").css("font-size", "16px");
		}
	}else if(action == "plus"){
		switch(plusSize){
			case "10px":
				$("#mid_con").css("font-size", "12px");
				$("h2").css("font-size", "15px");
				break;
			case "12px":
				$("#mid_con").css("font-size", "13px");
				$("h2").css("font-size", "16px");
				break;
			case "13px":
				$("#mid_con").css("font-size", "14px");
				$("h2").css("font-size", "18px");
				break;
			case "14px":
				$("#mid_con").css("font-size", "16px");
				$("h2").css("font-size", "20px");
				break;
			case "16px":
				$("#mid_con").css("font-size", "18px");
				$("h2").css("font-size", "22px");
				break;
			case "18px":
				$("#mid_con").css("font-size", "20px");
				$("h2").css("font-size", "24px");
				break;
			case "20px":
				$("#mid_con").css("font-size", "20px");
				$("h2").css("font-size", "24px");
				break;
			default:
				$("#mid_con").css("font-size", "13px");
				$("h2").css("font-size", "16px");
		
		}
	}
}


function bookmark(title,url){
	var brVar = "none";
	jQuery.each(jQuery.browser, function(i) {
		//alert("I = " + i);
		if($.browser.msie){
			brVar = 'internet explorer';
		}
		if($.browser.safari){
			brVar = 'safari';
		}
		if($.browser.mozilla){
			brVar = 'firefox';
		}
		if($.browser.opera){
			brVar = 'opera';
		}
		
    });

	var FF = brVar.search('firefox');
	var MSIE = brVar.search('internet explorer');
	var OP = brVar.search('opera');
	var SA = brVar.search('safari');
	
	if(FF >= 0){ // firefox
		window.sidebar.addPanel(title, url, "");
	}else if(OP >= 0){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(MSIE >= 0){ // IE
		window.external.AddFavorite(url, title);
	}else if(SA >= 0){ // Safari
		alert('If you are using Safari click command + D to bookmark.');
	}else{
		alert('Your browser does not support javascript bookmarking.');
	}
}


function slideTestimonial(direction){
	var cur = $("#currentTestimonial").val() | 0; // the OR (|) 0 casts this var as an integer
	//alert(cur);
	
	if(direction == "left"){
		switch (cur) {
			case 1: 
				// get in the starters box
				$("#testimonial3").hide();
				$("#testimonial3").css("left", "-915px");
				$("#testimonial3").show();
				
				//exit the stage
				$("#testimonial1").animate({ 
					left: "915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial3").animate({ 
					left: "0px",
					opacity: 1
				}, 1600 );

				// set new value
				$("#currentTestimonial").val("3");
				break;
			case 2: 
				// get in the starters box
				$("#testimonial1").hide();
				$("#testimonial1").css("left", "-915px");
				$("#testimonial1").show();
				
				//exit the stage
				$("#testimonial2").animate({ 
					left: "915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial1").animate({ 
					left: "0px",
					opacity: 1
				}, 1600 );

				// set new value
				$("#currentTestimonial").val("1");
				break;
			default: 
				// get in the starters box
				$("#testimonial2").hide();
				$("#testimonial2").css("left", "-915px");
				$("#testimonial2").show();
				
				//exit the stage
				$("#testimonial3").animate({ 
					left: "915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial2").animate({ 
					left: "0px",
					opacity: 1
				}, 1600 );

				// set new value
				$("#currentTestimonial").val("2");
		}// end switch
	}
	
	if(direction == "right"){
		switch (cur) {
			case 1: 
				// get in the starters box
				$("#testimonial2").hide();
				$("#testimonial2").css("left", "915px");
				$("#testimonial2").show();
				
				//exit the stage
				$("#testimonial1").animate({ 
					left: "-915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial2").animate({ 
					left: "0px",
					opacity: 1
				}, 1500 );

				// set new value
				$("#currentTestimonial").val("2");
				break;
			case 2: 
				// get in the starters box
				$("#testimonial3").hide();
				$("#testimonial3").css("left", "915px");
				$("#testimonial3").show();
				
				//exit the stage
				$("#testimonial2").animate({ 
					left: "-915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial3").animate({ 
					left: "0px",
					opacity: 1
				}, 1500 );

				// set new value
				$("#currentTestimonial").val("3");
				break;
			default: 
				// get in the starters box
				$("#testimonial1").hide();
				$("#testimonial1").css("left", "915px");
				$("#testimonial1").show();
				
				//exit the stage
				$("#testimonial3").animate({ 
					left: "-915px",
					opacity: 0
				}, 1500 );

				//enter the stage
				$("#testimonial1").animate({ 
					left: "0px",
					opacity: 1
				}, 1500 );

				// set new value
				$("#currentTestimonial").val("1");
		}// end switch
	}
	/*
	$("#block").animate({ 
		width: "70%",
		opacity: 0.4,
		marginLeft: "0.6in",
		fontSize: "3em", 
		borderWidth: "10px"
	}, 1500 );
	*/
}

function imgSwitch(id,file){
	document.getStarted.src='img/'+file;
	$("#"+id).css("cursor", "pointer");
	//$("#"+id).html("<img src=\"img/"+file+"\" name=\"getStarted\" width=\"200\" height=\"33\" border=\"0\">");
}

function stepByStep(dir){
	var current = $("#stepByStepVal").val();
	current = current * 1;

	if(dir == "left"){
		switch (current) {
			case 1: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step3").hide();
				$("#step2").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step5.jpg)");
				$("#stepByStepVal").val("5");
				
				// get in the starters box
				$("#step5").css("left", "-610px");
				$("#step5").show();
				
				//exit the stage
				$("#step1").animate({ 
					left: "610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step5").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				
				break;
			case 2: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step3").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step1.jpg)");
				$("#stepByStepVal").val("1");
				
				// get in the starters box
				$("#step1").css("left", "-610px");
				$("#step1").show();
				
				//exit the stage
				$("#step2").animate({ 
					left: "610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step1").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			case 3: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step2.jpg)");
				$("#stepByStepVal").val("2");
				
				// get in the starters box
				$("#step2").css("left", "-610px");
				$("#step2").show();
				
				//exit the stage
				$("#step3").animate({ 
					left: "610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step2").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			case 4: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step3").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("background-image","url(img/steps/step3.jpg)");
				$("#stepByStepVal").val("3");
				
				// get in the starters box
				$("#step3").css("left", "-610px");
				$("#step3").show();
				
				//exit the stage
				$("#step4").animate({ 
					left: "610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step3").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			default: 
				// hide divs off the stage
				$("#step4").hide();
				$("#step3").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step4.jpg)");
				$("#stepByStepVal").val("4");
				
				// get in the starters box
				$("#step4").css("left", "-610px");
				$("#step4").show();
				
				//exit the stage
				$("#step5").animate({ 
					left: "610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step4").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
		}// end switch
	}
	
	if(dir == "right"){
		switch (current) {
			case 1: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step3").hide();
				$("#step2").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step2.jpg)");
				$("#stepByStepVal").val("2");
				
				// get in the starters box
				$("#step2").hide();
				$("#step2").css("left", "610px");
				$("#step2").show();
				
				//exit the stage
				$("#step1").animate({ 
					left: "-610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step2").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			case 2: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step3").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step3.jpg)");
				$("#stepByStepVal").val("3");
				
				// get in the starters box
				$("#step3").hide();
				$("#step3").css("left", "610px");
				$("#step3").show();
				
				//exit the stage
				$("#step2").animate({ 
					left: "-610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step3").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			case 3: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step4").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step4.jpg)");
				$("#stepByStepVal").val("4");
				
				// get in the starters box
				$("#step4").hide();
				$("#step4").css("left", "610px");
				$("#step4").show();
				
				//exit the stage
				$("#step3").animate({ 
					left: "-610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step4").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			case 4: 
				// hide divs off the stage
				$("#step5").hide();
				$("#step3").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// hide divs off the stage
				$("#step5").hide();
				$("#step3").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("background-image","url(img/steps/step5.jpg)");
				$("#stepByStepVal").val("5");
				
				// get in the starters box
				$("#step5").css("left", "610px");
				$("#step5").show();
				
				//exit the stage
				$("#step4").animate({ 
					left: "-610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step5").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
				break;
			default: 
				// hide divs off the stage
				$("#step4").hide();
				$("#step3").hide();
				$("#step2").hide();
				$("#step1").hide();
				
				// set background
				$("#stepByStep").css("backgroundImage","url(img/steps/step1.jpg)");
				$("#stepByStepVal").val("1");
				
				// get in the starters box
				$("#step1").hide();
				$("#step1").css("left", "610px");
				$("#step1").show();
				
				//exit the stage
				$("#step5").animate({ 
					left: "-610px",
					opacity: 0
				}, 750 );

				//enter the stage
				$("#step1").animate({ 
					left: "20px",
					opacity: 1
				}, 750 );
		}// end switch
	}
}


function clearField(el){
	$("#"+el).val("");	
	document.getElementById(el).maxLength = 5;
}


// ============================================================================================
function checkOrderInfo(){
	
	var err = 0;
	var err_msg = 'Please correct the following: \r\n';
		
	if ($("#beneficiary_first_name").val() == ''){
		err = 1;
		err_msg += ' - Enter the beneficiary\'s first name.\r\n';
	}
	
	if ($("#beneficiary_last_name").val() == ''){
		err = 1;
		err_msg += ' - Enter the beneficiary\'s last name.\r\n';
	}	
	
	if ($("#beneficiary_relationship").val() == ''){
		err = 1;
		err_msg += ' - Enter the beneficiary\'s relationship with the purchaser.\r\n';
	}

	if ($("#beneficiary_address").val() == ''){
		err = 1;
		err_msg += ' - Enter the beneficiary\'s address.\r\n';
	}

	if ($("#beneficiary_city").val() == ''){
		err = 1;
		err_msg += ' - Enter the beneficiary\'s city.\r\n';
	}	

	if ($("#qwp_state").val() == ''){
		err = 1;
		err_msg += ' - Select the beneficiary\'s state.\r\n';
	}

	if ($("#beneficiary_zip").val().length < 5){
		err = 1;
		err_msg += ' - Enter a beneficiary\'s zip of at least 5 digits.\r\n';
	}
	
	if ($("#beneficiary_phone").val().length < 10){
		err = 1;
		err_msg += ' - Enter a beneficiary\'s phone of at least 10 characters.\r\n';
	}
	
	
	var ve = validEmail($("#beneficiary_email").val());
	if (ve == false){
		err = 1;
		err_msg += ' - Enter a valid beneficiary\'s email address.\r\n';		
	}
	
	
	if ($("#purchaser_first_name").val() == ''){
		err = 1;
		err_msg += ' - Enter the purchaser\'s first name.\r\n';
	}
	
	if ($("#purchaser_last_name").val() == ''){
		err = 1;
		err_msg += ' - Enter the purchaser\'s last name.\r\n';
	}	
	
	if ($("#purchaser_address").val() == ''){
		err = 1;
		err_msg += ' - Enter the purchaser\'s address.\r\n';
	}

	if ($("#purchaser_city").val() == ''){
		err = 1;
		err_msg += ' - Enter the purchaser\'s city.\r\n';
	}	

	if ($("#purchaser_state").val() == ''){
		err = 1;
		err_msg += ' - Select the purchaser\'s state.\r\n';
	}

	if ($("#purchaser_zip").val().length < 5){
		err = 1;
		err_msg += ' - Enter a purchaser\'s zip of at least 5 digits.\r\n';
	}
	
	if ($("#purchaser_phone").val().length < 10){
		err = 1;
		err_msg += ' - Enter a purchaser\'s phone of at least 10 characters.\r\n';
	}
	
	
	var ve = validEmail($("#purchaser_email").val());
	if (ve == false){
		err = 1;
		err_msg += ' - Enter a valid purchaser\'s email address.\r\n';		
	}	

	
	if (err > 0){
		alert(err_msg);
		return false;
	}
}



// ============================================================================================
function copyBeneficiaryInformation(el){
	
	var assocArr = new Array();
	assocArr["purchaser_first_name"] = "beneficiary_first_name";
	assocArr["purchaser_last_name"] = "beneficiary_last_name";
	assocArr["purchaser_address"] = "beneficiary_address";
	assocArr["purchaser_city"] = "beneficiary_city";
	assocArr["purchaser_state"] = "beneficiary_state";
	assocArr["purchaser_zip"] = "beneficiary_zip";
	assocArr["purchaser_phone"] = "beneficiary_phone";
	assocArr["purchaser_email"] = "beneficiary_email";	

	var x;	
	if ($("#"+el).is(":checked")){
		
		for (x in assocArr){			
			$("#"+x).val( $("#"+assocArr[x]).val() );
		}						
	}else{
		for (x in assocArr){			
			$("#"+x).val('');
		}
	}
}

// ============================================================================================
function calculateTotalDue(el, outputID, inputID){
		
	var product_ids = $("#cart_product_ids").val().split('|');	
	var totalDueNow = 0.00;
	
	for (i=0; i<product_ids.length; i++){
		var selectVal = $("#payment_option_"+product_ids[i]).val();
		
		if (selectVal == 'pay_in_full'){
			var fullPrice = $("#full_product_price_"+product_ids[i]).val();			
			totalDueNow = totalDueNow + parseFloat(fullPrice);
		}else{
			var downPayment = $("#down_payment_"+selectVal).val();
			totalDueNow = totalDueNow + parseFloat(downPayment);
		}
	}	
	
	$("#"+outputID).html('$' + CommaFormatted(totalDueNow));
	$("#"+inputID).val(totalDueNow);	
}



/* ============================================================================================
	CHANGES A NUMERIC VALUE INTO A MONEY FORMAT LIKE 23.00
	EXAMPLE:
		var value = 23;
		value = formatAsMoney(value);
		
		#value will now be 23.00
=============================================================================================== */
function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.ceil(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.ceil(mnt*10)) ? 
                       mnt + '0' : mnt);
}



/* ============================================================================================
	ADDS COMMAS TO NUMBERS GREATER THAN 999
=============================================================================================== */
function CommaFormatted(amount)
{
	// first, make sure it is a value with 2 decimal places
	amount = formatAsMoney(amount).toString();
	
	
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}


// ============================================================================================
function checkPaymentForm(){
	
	var err = 0;
	var err_msg = 'Please correct the following: \r\n';
		
	var ccCheck = checkCreditCard ($("#cardNumber").val(), $("#cardType").val());
	var ccDateCheck = checkccdate($("#cardExpYear").val(), $("#cardExpMonth").val());	
	//alert(ccCheck);
	
	if (ccCheck == false){
		err = 1;
		err_msg += ' - Enter a valid credit card number.\r\n';
	}
	
	if (ccDateCheck == false){
		err = 1;
		err_msg += ' - Enter a valid credit card expiration date.\r\n';
	}	
	
	
	if (err > 0){
		alert(err_msg);
		return false;
	}
}


// ============================================================================================
function checkCremationLead(){

	var err = 0;
	var err_msg = 'Please correct the following: \r\n';
	
	if ($("#first_name").val().length < 1){
		err = 1;
		err_msg += ' - Enter your first name.\r\n';
	}
	
	if ($("#last_name").val().length < 1){
		err = 1;
		err_msg += ' - Enter your last name.\r\n';
	}	

	var ve = validEmail($("#email").val());
	if (ve == false){
		err = 1;
		err_msg += ' - Enter a valid email address.\r\n';
	}
	
	if ($("#Phone").val().length < 10){
		err = 1;
		err_msg += ' - Enter a phone number of at least 10 characters.\r\n';
	}	
	
	if (err > 0){
		alert(err_msg);
		return false;
	}	
}















