function start_new_fundraiser_data_copy(){
	try {
	//$('#FundraiserNameOnCheck').attr('value', $('#UserFirstName').attr('value')+" "+$('#UserLastName').attr('value'));
	$('#FundraiserCheckAddressLine1').attr('value', $('#FundraiserOrganizationAddressLine1').attr('value'));
	$('#FundraiserCheckCity').attr('value', $('#FundraiserOrganizationCity').attr('value'));
	$('#FundraiserCheckState').attr('value', $('#FundraiserOrganizationState').attr('value'));
	$('#FundraiserCheckPostalCode').attr('value', $('#FundraiserOrganizationPostalCode').attr('value'));
	$('#FundraiserCheckUnit').attr('value', $('#FundraiserOrganizationUnit').attr('value'));
	} catch (ex){
	}
}

var mailer_count = 5;
var prev_row = mailer_count-1;
var row_count = mailer_count;

function mask_phone_number(){
	try {
		jQuery(function($){
			$(".phone_number").setMask("(999) 999-9999");
		});
	} catch (ex) {
	}
}

function CalculateFundsRaised(){
	try {
		number_of_team_members = $("#TeamMembersQty").attr('value').replace(/[^0-9\.]/g,'');
		units_sold = $("#UnitsSold").attr('value').replace(/[^0-9\.]/g,'');
		profit = $("#ProfitPerSale").attr('value').replace(/[^0-9\.]/g,'');
		total = number_of_team_members * units_sold * profit;
		$("#result").html('$'+total.toFixed(2));
	} catch (ex){
	}
} 
	
function add_mailer(){

	try {
	    var clonedRow = jQuery(".main-table tr:last").clone();
	
	    prev_row = jQuery('table.main-table tr').length - 2;
	    row_count = prev_row + 1;
	    jQuery("#User" + prev_row + "FirstName", clonedRow).attr("id", "User" + row_count + "FirstName");
	    jQuery("#User" + row_count + "FirstName", clonedRow).attr("name", "data[User][" + row_count + "][first_name]" ); 
	    jQuery("#User" + row_count + "FirstName", clonedRow).attr("value", "" );
	
	    
	    jQuery("#User" + prev_row + "LastName", clonedRow).attr("id", "User" + row_count + "LastName"); 
	    jQuery("#User" + row_count + "LastName", clonedRow).attr("name", "data[User][" + row_count + "][last_name]" ); 
	    jQuery("#User" + row_count + "LastName", clonedRow).attr("value", "" );
	
	    jQuery("#User" + prev_row + "EmailAddress", clonedRow).attr("id", "User" + row_count + "EmailAddress");
	    jQuery("#User" + row_count + "EmailAddress", clonedRow).attr("name", "data[User][" + row_count + "][email_address]" ); 
	    jQuery("#User" + row_count + "EmailAddress", clonedRow).attr("value", "" ); 
	
	    jQuery("#User" + prev_row + "PhoneNumber", clonedRow).attr("id", "User" + row_count + "PhoneNumber"); 
	    jQuery("#User" + row_count + "PhoneNumber", clonedRow).attr("name", "data[User][" + row_count + "][phone_number]" );
	    jQuery("#User" + row_count + "PhoneNumber", clonedRow).attr("value", "");
	    
	    jQuery("#User" + row_count + "PhoneNumber", clonedRow).setMask("(999) 999-9999");
	    jQuery("#User" + row_count + "CellPhoneNumber", clonedRow).setMask("(999) 999-9999");
	     //Now append the new row onto the end of the table
	    jQuery(".main-table").append(clonedRow);
		
	} catch (ex){
	}
	
    return false;

}

function remove_mailer(){
	if (row_count>5){
		row_count--;
		prev_row--;
		$(".main-table tr:last").remove();
	}
}

var px = window.parent.Shadowbox;

function OpenShadowWindow(url,string,width,height){
	if (!string){
		string="preview";
	}
	if (!width){
		width=730;
	}
	if (!height){
		height=550;
	}
		
	if (px){
		px.open({
	        content:    url,
	        player:     "iframe",
	        title:      string,
	        height:     height,
	        width:      width 
	    });
	}
}

jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ? 
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

Shadowbox.init({
	overlayColor: '#98AFC7',
    language: 'en',
    players:  ['img','html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
});

$(document).ready(function(){
	try {
		
		mask_phone_number();
		
		jQuery("div[id^='system_message']").filter(function(obj){
			
			string = jQuery("div[id^='system_message']").html();
			if (string.length>0){
				jQuery.gritter.add({
					title: 'FrontRunner Notice',
					text: string
				});
			}
		});
	
		
		/*
		if ($('div#preview_url') != null && $('div#preview_url').html() != '' ){
			my_url = $('div#preview_url').html();
			alert('lenght:'+my_url.length+" value:"+url_url)
			
			//this.OpenShadowWindow(my_url);
		} */
	
		jQuery(function($){
			$("#AccountExpiration").setMask("99/2099");
		});
	} catch (ex){
	}
	
	
});
