last_tab = "undefined";

function newsletter_overlay(which)
{
overlay_height = document.documentElement.scrollHeight;
document.getElementById('overlay').style.height = overlay_height + "px";
display_id('overlay','block');


	if(which == "template_a_front")
	{
	setup_centered_item('preview_template_a');
	display_id('preview_template','block');
	display_id('template_a_front','block');		
	}
	
	if(which == 'template_b_front')
	{
	setup_centered_item('preview_template_b');
	display_id('preview_template','block');
	display_id('template_b_front','block');		
	}
	
	if(which == 'template_a_back')
	{
	setup_centered_item('preview_template_a');
	display_id('preview_template','block');
	display_id('template_a_back','block');		
	}
	
	if(which == 'template_b_back')
	{	
	setup_centered_item('preview_template_b');
	display_id('preview_template','block');
	display_id('template_b_back','block');		
	}
	
	if(which == "newsletter_front")
	{
	setup_centered_item('newsletter_parts');
	display_id('newsletter_parts','block');
	display_newsletter_part('newsletter_front_images');
	display_id('front_cover_parts','block');
	}
	
	if(which == "newsletter_back")
	{
	setup_centered_item('newsletter_parts');
	display_id('newsletter_parts','block');
	display_newsletter_part('newsletter_back_images');
	display_id('back_cover_parts','block');
	}
	
}

function explain_newsletter_part(which)
{

	if(which == "info")
	{

	display_id('title_block', 'none');
	display_id('title_block_txt', 'none');
	
	display_id('letter_block', 'none');
	display_id('letter_block_txt', 'none');
	
	 display_id('info_block', 'block');
	 display_id('info_block_txt', 'block');	
	}
	
	if(which == "title")
	{
		
	display_id('info_block', 'none');
	display_id('info_block_txt', 'none');	
	
	display_id('letter_block', 'none');
	display_id('letter_block_txt', 'none');
	
	display_id('title_block', 'block');
	display_id('title_block_txt', 'block');
	
	}
	
	if(which == "letter")
	{
	
	display_id('info_block', 'none');
	display_id('info_block_txt', 'none');	
	
	display_id('title_block', 'none');
	display_id('title_block_txt', 'none');
	
	
	display_id('letter_block', 'block');
	display_id('letter_block_txt', 'block');
	}
	
	if(which == "info_2")
	{
	display_id('prepared_block', 'none');
	display_id('prepared_block_txt', 'none');
	
	display_id('customizable_block', 'none');
	display_id('customizable_block_txt', 'none');
	
	display_id('title_block_2', 'none');
	display_id('title_block_txt', 'none');	
	
	display_id('info_block_2', 'block');
	display_id('info_block_txt', 'block');	
	
	}
	
	if(which == "title_2")
	{
	display_id('prepared_block', 'none');
	display_id('prepared_block_txt', 'none');
	
	display_id('customizable_block', 'none');
	display_id('customizable_block_txt', 'none');	
	
	display_id('info_block_2', 'none');
	display_id('info_block_txt', 'none');	
		
	display_id('title_block_2', 'block');
	display_id('title_block_txt', 'block');		
	}
	
	if(which == "customizable")
	{
	
	display_id('info_block_2', 'none');
	display_id('info_block_txt', 'none');
		
	display_id('prepared_block', 'none');
	display_id('prepared_block_txt', 'none');
	
	display_id('title_block_2', 'none');
	display_id('title_block_txt', 'none');	
	
	display_id('customizable_block', 'block');
	display_id('customizable_block_txt', 'block');	
	
	}
	
	if(which == "prepared")
	{
	
	display_id('info_block_2', 'none');
	display_id('info_block_txt', 'none');
	
	display_id('customizable_block', 'none');
	display_id('customizable_block_txt', 'none');
	
	display_id('title_block_2', 'none');
	display_id('title_block_txt', 'none');	
	
	display_id('prepared_block', 'block');
	display_id('prepared_block_txt', 'block');
	
	
	}
	
		
}

function close_newsletter_overlay(which)
{
	
	if(which == "preview_template")
		{
		display_id('template_a_front','none');
		display_id('template_b_front','none');
		display_id('template_a_back','none');
		display_id('template_b_back','none');
		display_id('preview_template','none');	
		}
	else
		{
		display_id('info_block', 'none');
		display_id('info_block_txt', 'none');	
		
		display_id('letter_block', 'none');
		display_id('letter_block_txt', 'none');
		
		display_id('title_block', 'none');
		display_id('title_block_txt', 'none');
		
		display_id('prepared_block', 'none');
		display_id('prepared_block_txt', 'none');
		
		display_id('customizable_block', 'none');
		display_id('customizable_block_txt', 'none');	
		
		display_id('info_block_2', 'none');
		display_id('info_block_txt', 'none');
		
		display_id('title_block_2', 'none');
		display_id('title_block_txt', 'none');
		
		display_id('newsletter_parts', 'none');	
		}

		display_id('overlay','none');

}

function show_overlay(which)
{
overlay_height = document.documentElement.scrollHeight;
document.getElementById('overlay').style.height = overlay_height + "px";
display_id('overlay','block');
setup_centered_item('chart');
display_id(which, 'block');
display_id('chart','block');
	
}

function close_overlay()
{

display_id('ease','none');
display_id('ease_regularity','none');
display_id('attention','none');
display_id('personalized','none');
display_id('appeal','none');
display_id('cost','none');
display_id('shelf','none');


display_id('chart','none');
display_id('overlay','none');



}


function setup_centered_item(itemId)
{
  myWidth = 0; 
  myHeight = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
	
  }
  
  if(itemId == "chart")
  	{
  top_of_item = (myHeight - 380) / 2;
  left_of_item = (myWidth - 600) / 2;
	}

 if(itemId == "newsletter_parts")
 	{
 	top_of_item = (myHeight - 450) / 2;
  left_of_item = (myWidth - 750) / 2;	
	}
	
 if(itemId == "preview_template_a")
 	{
 	top_of_item = (myHeight - 378) / 2;
  left_of_item = (myWidth - 300) / 2;
  itemId = "preview_template";
  document.getElementById(itemId).style.height = 378 + "px";
	}

 if(itemId == "preview_template_b")
 	{
 	top_of_item = (myHeight - 455) / 2;
  left_of_item = (myWidth - 280) / 2;
   itemId = "preview_template";
   document.getElementById(itemId).style.height = 465 + "px";
	}
  
	document.getElementById(itemId).style.top = top_of_item + "px";
	document.getElementById(itemId).style.left = left_of_item + "px";
 
  	/*
	var d = document.documentElement;
	alert("DE scrollh:" + d.scrollHeight);
	alert("DE offesth:" + d.offsetHeight);
	
	var b = document.body;
	alert("B scrollh:" + b.scrollHeight);
	alert("B offesth:" + b.offsetHeight);
	*/
  
}


function swap_image(obj_id, which_image)
{
document.getElementById(obj_id).src = "images/" + which_image;	
	
}

function show_sub_links(sub_link_id)
{
obj = document.getElementById(sub_link_id);
display_it(obj, "block");		
}

function hide_sub_links(sub_link_id)
{
obj = document.getElementById(sub_link_id);
display_it(obj, "none");		
}


function display_it(obj, status)
{
obj.style.display=status;
}

function display_id(id, status)
{
obj = document.getElementById(id);
obj.style.display=status;
	
}

function move_tab(where)
{
	tabobj = document.getElementById('white_tab');
	linkobj = document.getElementById('link_' + where);
	linkobj.style.color="#5260a9";


if (last_tab != "undefined" && last_tab != where)
	{
	document.getElementById('link_' + last_tab).style.color="white";		
	}

last_tab = where;

	
if (where == "home")
	{
		tabobj.style.right = '605px';	
	}
else if (where == "1")
	{
		tabobj.style.right = '237px';	
	}
else if (where == "2")
	{
		tabobj.style.right = '492px';	
	}
else if (where == "3")
	{
		tabobj.style.right = '358px';	
	}
	
else if (where == "4")
	{
		tabobj.style.right = '112px';	
	}
	
else if (where == "5")
	{
		tabobj.style.right = '112px';	
	}

}

function restore_tab(where)
{
	
	linkobj = document.getElementById('link_' + where);
	
	tab_restore_timer =  setTimeout("linkobj.style.color='white';move_tab(tab_origin);", 1200);
	
}

function display_newsletter_part(part_id)
{
if(part_id == "newsletter_front_images")
	{
		display_id('newsletter_front_images', 'block');
		display_id('front_cover_parts', 'block');
		
		display_id('newsletter_back_images' , 'none');
		display_id('back_cover_parts', 'none');
		
		display_id('newsletter_inside_images' , 'none');
		
	}

if(part_id == "newsletter_back_images")
	{
		display_id('newsletter_front_images' , 'none');
		display_id('front_cover_parts', 'none');
		
		display_id('newsletter_back_images', 'block');
		display_id('back_cover_parts', 'block');
		
		display_id('newsletter_inside_images' , 'none');	
	}
	
if(part_id == "newsletter_inside_images")
	{
		display_id('newsletter_back_images', 'none');
		display_id('back_cover_parts', 'none');
		
		display_id('newsletter_front_images' , 'none');
		display_id('front_cover_parts', 'none');
		
		display_id('newsletter_inside_images' , 'block');	
	}
	
}

function display_sublinks(which)
{
	

if(which == "home")
	{
		move_tab('home');
		
		display_id('sub_links_2', 'none');
		display_id('sub_links_3', 'none');
		display_id('sub_links_4', 'none');
		display_id('sub_links_5', 'none');
		
		
		clear_timer('home');
		
	}


if(which == 1)
	{
		move_tab('1');
		
		display_id('sub_links_2', 'none');
		display_id('sub_links_3', 'none');
		display_id('sub_links_4', 'none');
		display_id('sub_links_5', 'none');
		
		
		clear_timer(1);
		display_id('sub_links_1', 'block');	
		
	}
	
if(which == 2)
	{
		move_tab('2');
		
		display_id('sub_links_1', 'none');
		display_id('sub_links_3', 'none');
		display_id('sub_links_4', 'none');
		display_id('sub_links_5', 'none');
		
		
		clear_timer(2);
		display_id('sub_links_2', 'block');	
		
	}

if(which == 3)
	{
		move_tab('3');
		
		display_id('sub_links_1', 'none');
		display_id('sub_links_2', 'none');
		display_id('sub_links_4', 'none');
		display_id('sub_links_5', 'none');
		
		
		clear_timer(3);
		display_id('sub_links_3', 'block');	
		
	}
	
if(which == 4)
	{
		move_tab('4');
		
		display_id('sub_links_1', 'none');
		display_id('sub_links_2', 'none');
		display_id('sub_links_3', 'none');
		display_id('sub_links_5', 'none');
		
		
		clear_timer(4);
		display_id('sub_links_4', 'block');	
		
	}

if(which == 5)
	{
		move_tab('5');
		
		display_id('sub_links_1', 'none');
		display_id('sub_links_2', 'none');
		display_id('sub_links_3', 'none');
		display_id('sub_links_4', 'none');
		
		
		clear_timer(5);
		display_id('sub_links_5', 'block');	
		
	}
	
	

}
	

function start_timer(which)
	{
		
	if(which == "home")
		{
		restore_tab('home');	
		}
	
	if(which == 1)
		{
		link_1_timer = setTimeout("display_id('sub_links_1', 'none');", 600);
		restore_tab('1');
		}
	
	if(which == 2)
		{
		link_2_timer = setTimeout("display_id('sub_links_2', 'none');", 600);
		restore_tab('2');
		}
	
	if(which == 3)
		{
		link_3_timer = setTimeout("display_id('sub_links_3', 'none');", 600);
		restore_tab('3');
		}
	
	if(which == 4)
		{
		link_4_timer = setTimeout("display_id('sub_links_4', 'none');", 600);
		restore_tab('4');
		}
	
	if(which == 5)
		{
		link_5_timer = setTimeout("display_id('sub_links_5', 'none');", 600);
		restore_tab('5');
		}
		
	}
	
function clear_timer(which)
	{
		
	if(typeof(tab_restore_timer) != "undefined")
			{
			clearTimeout(tab_restore_timer);
			}
	
	if(which == 1)
		{
			
		if(typeof(link_1_timer) != "undefined")
			{
			clearTimeout(link_1_timer);
			}
		}
	if(which == 2)
		{
		if(typeof(link_2_timer) != "undefined")
			{
			clearTimeout(link_2_timer);
			}
		}
	
	if(which == 3)
		{
		if(typeof(link_3_timer) != "undefined")
			{
			clearTimeout(link_3_timer);
			}
		}
	
	if(which == 4)
		{
		if(typeof(link_4_timer) != "undefined")
			{
			clearTimeout(link_4_timer);
			}
		}	
	
	if(which == 5)
		{
		if(typeof(link_5_timer) != "undefined")
			{
			clearTimeout(link_5_timer);
			}
		}
		
		
	}
	

function show_the_meat(when)
{
if(when == "now")
	{
	display_id('content_text2', 'block');
	}
else
	{
setTimeout("display_id('content_text2', 'block');",16000);
	}
}

function postData(url, data, handler_function_id)
{	
	//alert('running postdata');
	
	//alert('data' + data);
	
	 XMLHttpRequestObject = false;

	if (window.XMLHttpRequest) 
		{
		XMLHttpRequestObject = new XMLHttpRequest();
		}
	else if (window.ActiveXObject) 
		{
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
	if(XMLHttpRequestObject)
	{
	//alert('xml_object_defined');
	
	XMLHttpRequestObject.open("POST", url);
	XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	XMLHttpRequestObject.onreadystatechange = function()
		{
			//alert('xml_object_state_changed');
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
			{
			response = XMLHttpRequestObject.responseText;
			delete XMLHttpRequestObject;
			XMLHttpRequestObject = null;
			//alert("handler_id:" + handler_function_id);
			handle_server_answer(handler_function_id, response);

			
			
			}	
		}
	XMLHttpRequestObject.send(data);
	}
	
	

}

function handle_server_answer(handler_function_id, response)
{
	if(handler_function_id == "view_imprint")
		{
			document.getElementById('preview_div').innerHTML = response;
			display_id('preview_div','block');
			
		}
	
	
}

function get_details(event, which)
{
	
if (document.all) 
	{
    mouseX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;	
	}
else
	{	
	//mouseX = event.pageX + document.body.scrollLeft; 
	//mouseY = event.pageY + document.body.scrollTop;
	
	mouseX = event.pageX;
	mouseY = event.pageY;
	
	}
	
offset = 30;


obj = document.getElementById('preview_div');

mouseY = mouseY + offset;
mouseX = mouseX + offset;

obj.style.top  = mouseY  + 'px';
obj.style.left = mouseX  + 'px';

if(which == "show_logo_thumb")
	{	
	view_image("logo", "thumb");	
	}

if(which == "show_imprint")
	{
	view_imprint();
	}

}

function hide_details()
{
document.getElementById('preview_div').innerHTML = " ";	
display_id("preview_div","none");

}

function view_image(which, size)
{
	if (which == "logo" && size == "thumb")
	{
		display_id('preview_div','block');
		document.getElementById('preview_div').innerHTML = "<img src='get_thumb.php?which=logo'/>"
		
	}
	
	
}

function view_imprint()
{
		url="get_info.php";
		data="which=imprint";
		handler_function_id = "view_imprint";
		postData(url, data, handler_function_id);
		
}


function preview_template()
{
display_id("template_1", "none");
display_id("template_2", "none");

template_selected = document.getElementById('template').value;
temp_div = "template_" + template_selected;
display_id("template_div", "block");
display_id(temp_div, "block");
	
}

function change_newsletter_title()
{
newsletter_title_id = document.getElementById('newsletter_title').value;

if(newsletter_title_id == "9999")
	{
	display_id("write_title", "block");		
	}
else
	{
	display_id("write_title", "none");		
	}
	
}

function change_newsletter_title_new()
{
 title_source = document.forms['update_title'].elements['newsletter_title_source'];
 if(title_source[1].checked) 
 	{
	display_id("provided_title", "none");	
	display_id("write_title", "block");		
	}
 else
 	{
	display_id("write_title", "none");
	display_id("provided_title", "block");	
	}
}

function change_newsletter_subtitle()
{
newsletter_subtitle_id = document.getElementById('newsletter_subtitle').value;

if(newsletter_subtitle_id == "9999")
	{
	display_id("write_subtitle", "block");		
	}
else
	{
	display_id("write_subtitle", "none");		
	}
	
}

function change_newsletter_subtitle_new()
{
 subtitle_source = document.forms['update_title'].elements['newsletter_subtitle_source'];
 if(subtitle_source[1].checked) 
 	{
	display_id("provided_subtitle", "none");	
	display_id("write_subtitle", "block");		
	}
 else
 	{
	display_id("write_subtitle", "none");
	display_id("provided_subtitle", "block");
	}
	
}

function change_plan_desc()
{
	
which_plan = document.getElementById('plan').value;

if(which_plan == "silver")
	{
		
	display_id('description','none');
	display_id('gold_desc', 'none');
	display_id('platinum_desc','none');
	display_id('silver_desc','block');

		
	}

if(which_plan == "gold")
	{
		
	display_id('description','none');
	display_id('silver_desc', 'none');
	display_id('platinum_desc','none');
	display_id('gold_desc','block');	
		
		
	}
	
if(which_plan == "platinum")
	{
		
	display_id('description','none');
	display_id('silver_desc', 'none');
	display_id('gold_desc','none');
	display_id('platinum_desc','block');
	
	}
	

if(which_plan == "none")
	{
		
	
	display_id('silver_desc', 'none');
	display_id('gold_desc','none');
	display_id('platinum_desc','none');
	display_id('description','block');
	
	}
			
}



function display_cost()
{

num_of_customers = document.getElementById('num_customers').value;
startup_fee = 175.00;

if (num_of_customers > 0)
	{
	
	selected_plan = document.getElementById('plan').value;
	
	if (selected_plan == "silver")
		{
			num_of_issues = 4;
								
				if(num_of_customers > 0 && num_of_customers < 250)
				{
					issue_cost_per_customer =	1.65;
				}
				
			if(num_of_customers >= 250 && num_of_customers <500)
				{
					issue_cost_per_customer =	1.45;
				}
					
			if (num_of_customers >= 500 && num_of_customers <2000)
				{
					issue_cost_per_customer =	1.45;
					
				}
				
			if	(num_of_customers >= 2000 && num_of_customers <2500)
				{
					issue_cost_per_customer =	1.35;
					
				}
				
			if	(num_of_customers >= 2500 && num_of_customers <3000)
				{
					issue_cost_per_customer =	1.35;
					
				}
			
			if (num_of_customers >= 3000 && num_of_customers <4000)
				{	
					issue_cost_per_customer =	1.25;
					
				}
				
			if	(num_of_customers >= 4000 && num_of_customers <5000)
				{	
					issue_cost_per_customer =	1.20;
				}
		
			if	(num_of_customers >= 5000)
				{
					issue_cost_per_customer =	1.15;
				}
			
		}
		
		
		if (selected_plan == "gold")
		{
			num_of_issues = 6;
			
			
				if(num_of_customers > 0 && num_of_customers <250)
					{
					issue_cost_per_customer =	1.50;
					}
					
				if(num_of_customers >= 250 && num_of_customers <500)
					{
					issue_cost_per_customer =	1.30;
					}
					
				if(num_of_customers >= 500 && num_of_customers <2000)
					{
					issue_cost_per_customer =	1.30;
					}
				
				if(num_of_customers >= 2000 && num_of_customers <2500)
					{
					issue_cost_per_customer =	1.20;
					}
				
				if(num_of_customers >= 2500 && num_of_customers <3000)
					{
					issue_cost_per_customer =	1.10;
					}
					
				if(num_of_customers >= 3000 && num_of_customers <4000)
					{
					issue_cost_per_customer =	1.10;
					}
					
				if(num_of_customers >= 4000 && num_of_customers <5000)
					{
					issue_cost_per_customer =	1.05;
					}
		
				if(num_of_customers >= 5000)
					{
					issue_cost_per_customer =	1.00;
					}
		}
		
		if (selected_plan == "platinum")
		{
			num_of_issues = 8;
			
				if (num_of_customers > 0 && num_of_customers <250)
				{
					issue_cost_per_customer =	1.40;
				}
				
			if (num_of_customers >= 250 && num_of_customers <2000)
				{
					issue_cost_per_customer =	1.20;
				}
				
			if (num_of_customers >= 2000 && num_of_customers <2500)
				{
					issue_cost_per_customer =	1.10;
				}
				
			if	(num_of_customers >= 2500 && num_of_customers <3000)
				{
					issue_cost_per_customer =	1.10;
				}
					
			if	(num_of_customers >= 3000 && num_of_customers <4000)
				{	
					issue_cost_per_customer =	1.00;
				}
					
			if	(num_of_customers >= 4000 && num_of_customers <5000)
				{	
					issue_cost_per_customer =	.95;
				}
		
			if	(num_of_customers >= 5000)
				{	
					issue_cost_per_customer =	.90;
				}
				
		}
		
		if(selected_plan != "none")
		{
			 
			total_cost_per_issue = num_of_customers * issue_cost_per_customer;
			yearly_cost_each_customer = num_of_issues * issue_cost_per_customer;
			yearly_total_cost = num_of_issues * num_of_customers * issue_cost_per_customer;
			total_due_amount = total_cost_per_issue + startup_fee;
			
			document.getElementById('issue_cp_customer').innerHTML = "<div align='right' style='padding-right:10px;'>" + "$" +issue_cost_per_customer.toFixed(2) + "</div>";
			document.getElementById('total_cp_issue').innerHTML = "<div align='right' style='padding-right:10px;'>" + "$" + total_cost_per_issue.toFixed(2) + "</div>";
			
			document.getElementById('yearly_cp_customer').innerHTML = "<div align='right' style='padding-right:10px;'>" + "$" +yearly_cost_each_customer.toFixed(2) + "</div>";
			
			document.getElementById('total_cp_year').innerHTML = "<div align='right' style='padding-right:10px;'>" + "$" +yearly_total_cost.toFixed(2) + "</div>";
			
			document.getElementById('total_due').innerHTML = "$" + total_due_amount.toFixed(2);
			
			document.getElementById('total_due_field').value = total_due_amount;
			
			display_id('cost_breakdown', 'block');	
		}
		else
		{
			display_id('cost_breakdown', 'none');		
		}
		
		
	}
	else
		{
			display_id('cost_breakdown', 'none');	
		}
		
		
}

function checkLUHN(ccard)
{

last_digit = ccard.length-1; //length of string "abcdefghij" is 10 but index is 0 thru 9
sum_of_digits = 0;
double_digit = false;
for(i = last_digit; i>-1; i--)
 	{
	digit = parseInt(ccard.charAt(i));
		
	if (!double_digit)
		{
		sum_of_digits += digit;
		double_digit = true;
		}
	else
		{
		digit *=2;
		
		 if (digit<10)
		 	{
			sum_of_digits += digit;
			}
		 else
		 	{
			sum_of_digits += (digit % 10) + 1;
			}
		double_digit = false;
		}
	}
	
if (sum_of_digits % 10 != 0)
	{
	ccard_error = true;
	ccard_error_msg = "Invalid Card Number (Didn't pass LUHN)";
	}

}

function check_ccard()
{
ccard = document.getElementById('ccard').value;
ccard_error_msg = " ";
ccard_error = false;

if(ccard.length <13 || ccard.length >16)
	{
	ccard_error = true;
	ccard_error_msg = "Card Numbers are between 13 and 16 characters";
	}
	else
	{
		if(ccard.length == 13) //possibly a Visa if it starts with 4
		{
			if (ccard.charAt(0) != '4')
				{
				ccard_error = true;
				ccard_error_msg = "Invalid Card Number (13 digits and first char != 4)";
				}
			else
				{
				checkLUHN(ccard);
				}
		}
		
		if(ccard.length == 14) //possibly a Diners Club....we don't accept
		{
			
				ccard_error = true;
				ccard_error_msg = "Invalid Card Number (14 digits not accepted)";

		}
		
		if(ccard.length == 15)//possibly a Amex if it starts with 34 or 37
		{
	
			if ( parseInt(ccard.substring(0,2)) != 34 && parseInt(ccard.substring(0,2)) != 37)
				{
				ccard_error = true;
				ccard_error_msg = "Invalid Card Number (15 digits and first chars !=34 or !=37)";			
				}
			else
				{
				checkLUHN(ccard);
				}
		
		}
		
		if(ccard.length == 16)//possibly a Mastercard, Discover, Visa 
		{
			if (parseInt(ccard.substring(0,2)) >= 51 && parseInt(ccard.substring(0,2)) <= 55) //could be a MasterCard
				{
				checkLUHN(ccard);			
				}
				
			else if(ccard.charAt(0) == '4') //could be a Visa
				{
				checkLUHN(ccard);
				}
			
			else if(ccard.substring(0,4) == "6011") //could be Discover
				{
				checkLUHN(ccard);
				}
			else
				{
				ccard_error = true;
				ccard_error_msg = "Invalid Card Number (16 digits and first chars incorrect)";
				}
		
		}
		
		
	}

if(ccard_error)
	{
	alert(ccard_error_msg);
	return false;
	}
else
	{
	return true;	
	}


}

function checkform() {

something_missing = false;
make_selection = false;
error=""

name = document.forms['checkout'].elements['name'].value;
company = document.forms['checkout'].elements['company'].value;
address = document.forms['checkout'].elements['address'].value;
address2 = document.forms['checkout'].elements['address2'].value
city = document.forms['checkout'].elements['city'].value;
state = document.forms['checkout'].elements['state'].value;
zip = document.forms['checkout'].elements['zip'].value;
phone = document.forms['checkout'].elements['phone'].value;
email = document.forms['checkout'].elements['email'].value;




if (name.length == 0)
{
something_missing = true;
error = "Please Specify Your Name\n";
}

if (company.length == 0)
{
something_missing = true;
error = error  + "Please Specify Your Company Name\n";
}

if (address.length == 0)
{
something_missing = true;
error = error  + "Please Specify Your Street Address\n";
}


if (city.length == 0)
{
something_missing = true;
error = error + "Please Specify Your City\n";
}

if (state.length == 0)
{
something_missing = true;
error = error + "Please Specify Your State\n";
}

if (zip.length < 5)
{
something_missing = true;
error = error + "Please Specify The Zip Code\n";
}

if(phone.length < 10)
{
something_missing = true;
error = error + "Please Specify The Phone Number\n";
}

	if(email.length == 0)
	{
	something_missing = true;
	error = error + "Please Specify The Email Address\n";
	}



	if (something_missing) 
	{
	alert(error);
	return false;
	}

	if (!check_ccard())
	{
	return false;
	}
}


function ccv_popup()
	{
	window.open('cvv.html','cvv_window', 'toolbars=0,scrollbars=0, location=0,statsubar=0,menubar=0,resiable=0,width=590,height=245,left=490,top=312');
	return false;
	}
	
 why_newsletters_sub = "hidden";
newsletter_plans_sub ="hidden";
 next_steps_sub ="hidden";
 main_testimonials = "visible";
 num_visible=0;


$(document).ready(function(){

$("#get_tf_answer").click(function(){
  
  	$("#tf_question").hide('fold', '500');
	$("#get_tf_answer").hide('fold', '500');
	$("#tf_answer").show('fold', '500');
						
  });		  		



  $("#why_newsletters_a").click(function(){
  
  
		  if(why_newsletters_sub == "hidden")
		  {
		  	  if(main_testimonials == "visible")
			  	{	
		  	  		$("#main_testimonials").hide('fold', '500');
						main_testimonials = "hidden";	
			  	}	
				
			  $("#why_newsletters_submenu").show('slide',{ direction: "up" });
			  why_newsletters_sub = "visible";
			  num_visible +=1;
			 
		  }
		  else
		  {
			  $("#why_newsletters_submenu").hide('slide',{ direction: "up" });
			  why_newsletters_sub = "hidden";
			  num_visible -=1;
			  
			  if(num_visible == 0)
			  	{
				 $("#main_testimonials").show('fold', '500');
				 main_testimonials = "visible";	
				}
			
		  }
  });
  
   $("#newsletter_plans_a").click(function(){
   
  		if(newsletter_plans_sub == "hidden")
		{
			if(main_testimonials == "visible")
			  	{	
		  	  		$("#main_testimonials").hide('fold', '500');
						main_testimonials = "hidden";	
			  	}	
					
  			$("#newsletter_plans_submenu").show('slide',{ direction: "up" });
			newsletter_plans_sub = "visible";
			  num_visible +=1;
  		}
		else
		{
			$("#newsletter_plans_submenu").hide('slide',{ direction: "up" });
			newsletter_plans_sub = "hidden";
			num_visible -=1;
			
			 
			  if(num_visible == 0)
			  	{
				 $("#main_testimonials").show('fold', '500');
				  main_testimonials = "visible";		
				}
		
		}
  });		
  
   $("#next_steps_a").click(function(){

	  if(next_steps_sub == "hidden")
	  {
	  	
		if(main_testimonials == "visible")
			  	{	
		  	  		$("#main_testimonials").hide('fold', '500');
						main_testimonials = "hidden";	
			  	}	
				
	  	 $("#next_steps_submenu").show('slide',{ direction: "up" });
		 next_steps_sub = "visible"
		   num_visible +=1;
	  
	  }
	  else
	  {
	  
	  $("#next_steps_submenu").hide('slide',{ direction: "up" });
	  next_steps_sub = "hidden";
	  num_visible -=1;
	  
	   
			  if(num_visible == 0)
			  	{
				 $("#main_testimonials").show('fold', '500');
				  main_testimonials = "visible";		
				}
	  
	  }	
	 
});
	 
});


