/*//NEW TEMPLATE*/
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


//Main Menu Start
var main_menu = 
{
	"current_id": null,
	"menu_item_bgcolor": '#167a95',
	"submenu_item_default_bgcolor": '#F3F3F3',
	"a_color": '#5B5B5B',
	"menu_open": function (id) 
	{
		if ($('#hidden' + id).length != 0)
		{
			$('#hidden' + id).show();
		}
		$('#shown' + this.current_id).css('background','');
		if (id != 9)
			$('#shown' + id).css('background',this.menu_item_bgcolor);
		if (id == 9 || this.current_id == 9)
		{
			$('#shown9').css('background-image','url(/images/header/bgbutton-hover.gif)');
			$('#shown9 a').css('color','white');
		}
		if (id == 10 || this.current_id == 10)
		{
			$('#shown10 a').css('color','white');
		}
		if (id != 10 && this.current_id == 10)
		{
			$('#shown10 a').css('color','#FFD03F');
		}

	}, 
	
	"menu_close": function (id) 
	{
		if ($('#hidden' + id).length != 0)
		{
			$('#hidden' + id).hide();
		}
		
		if (id != 9)
		{
			$('#shown' + id).css('background','');
		}
		else
		{
			if (this.current_id != 9)
			{
				$('#shown9').css('background-image','url(/images/header/bgbutton-regular.gif)');
				$('#shown9 a').css('color','black');
			}
		}
		
		
		
		$('#shown' + this.current_id).css('background',this.menu_item_bgcolor);

		if (this.current_id == 9)
		{
			$('#shown9').css('background-image','url(/images/header/bgbutton-hover.gif)');
			$('#shown9 a').css('color','white');
		}
		if (this.current_id == 10)
		{
			$('#shown10 a').css('color','white');
		}
		else
		{
			$('#shown10 a').css('color','#FFD03F');
		}
	},
	
	"menu_item_color": function (obj) 
	{
		obj.css('background',this.menu_item_bgcolor);
		obj.find('a').css('color','white');
	},
	
	"menu_item_no_color": function (obj) 
	{ 
		obj.css('background',this.submenu_item_default_bgcolor);
		obj.find('a').css('color',this.a_color);
	},

	"attachEvents": function(first_id)
	{
		if (first_id != 9)
		{
			$('#shown' + first_id).css('background',this.menu_item_bgcolor);
		}
		else		
		{
			$('#shown' + first_id).css('background-image','url(/images/header/bgbutton-hover.gif)');
			$('#shown' + first_id + ' a').css('color','white');
		}
		if (first_id == 10)
		{
			$('#shown10 a').css('color','white');
		}

		
		var that = this;
		$('.main_menu_item').each(function()
		{
			var that2 = that;
			var id = $(this).attr('id').replace('shown','');
			
			$(this).mouseover(function(){
				that2.menu_open(id);
			});
			$(this).mouseout(function(){
				that2.menu_close(id);
			});
		});
		
		$('.topnode').each(function(){
			var that2 = that;
			var obj = $(this);
			$(this).mouseover(function(){
				that2.menu_item_color(obj);
			});
			$(this).mouseout(function(){
				that2.menu_item_no_color(obj);
			});
		});
	}

}

//Main Menu End

//Start Public Pages 3 Columns

var equalizeCols = function(divs)
{
	
    var maxH = 0;
    divs.each(
      function(i) 
      {
      	var thisHeight = $(this).height() + parseInt($(this).css("padding-top")) +  parseInt($(this).css("padding-bottom"));
        if (thisHeight > maxH) 
        {
        	maxH = thisHeight;
        }
      }
    ).each(
      function(i) 
      {
      	if (($(this).height() + parseInt($(this).css("padding-top")) +  parseInt($(this).css("padding-bottom"))) != maxH)
      	{
	      	$(this).height(maxH)
	    }
      }
    );
}

//End Public Pages 3 Columns

//Start ValidationMethods
var validationMethods = 
{
	"validateEmail": function(email)
	{
		var filter  = /^[\+_a-zA-Z0-9-]+(\.[\+_a-zA-Z0-9-]+)*\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/i;
		if (filter.test(email))
			return true;
		else
			return false;

	}, 
	
	"validateURL": function(url)
	{
		// Must be the same as isUrl
		if (url.toLowerCase().substring(0,7) != 'http://')
		{
			//url = url.substring(7,url.length)
			url = 'http://'+url;
		}
		var v = new RegExp();
	    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	    if (!v.test(url)) {
	        return false; 
	    }
	    return true;
	}, 
	
	"validateRequired": function(field)
	{
		if ((field.required) && (!field.value))
		{
			return false;
		}
		else
		{
			return true;
		}
	},
	
	"minLength": function(field)
	{
		if ((field.minLength) && (field.value.length < field.minLength))
		{
			return false;
		}
		else
		{
			return true;
		}
	},
	
	"markErrors": function(fields)
	{
		var hasErrors = false;
		$.each(fields, function(){
			if (this.error == 1)
			{
				$('#'+this.inputId+'_text').css('color', 'red');
				hasErrors = true;
			}
		});
		/*if (hasErrors)
		{
			window.scrollTo(0, 0);
		}*/
		return hasErrors;
	}, 
	
	"clearErrors": function(fields)
	{
		$.each(fields, function(){
				$('#'+this.inputId+'_text').css('color', 'black');
				validationMethods.showInputErrorBox(this.inputId,'');
		});
		this.showErrorBox('');
		
	}, 
	
	"validateCompare": function(txt1, txt2)
	{
		if (txt1 == txt2)
		{
			return true;
		}
		else
		{
			return false;
		}
	}, 
	
	"showErrorBox": function(msg)
	{
		if (msg)
		{
			$('#error_box').show();
			$('#error_box_message').text(msg);
		}
		else
		{
			$('#error_box').hide();
			$('#error_box_message').text('');
		}
	}, 
	
	"showInputErrorBox": function(input_id, msg)
	{		
		if (msg)
		{
			$('#'+input_id + '_error_box').show();
			$('#'+input_id + '_error_box').text(msg);
			$('#'+input_id ).addClass('input_error');
		}
		else
		{
			$('#'+input_id + '_error_box').hide();
			$('#'+input_id ).removeClass('input_error');
		}
	},
	
	"loadingAnimation": function()
	{
		$('#button_box button').each(function(){
			$(this).toggle();
		});
		$('#button_box .reg_button').each(function(){
			$(this).toggle();
		});
		$('#button_box .reg_button_trial').each(function(){
			$(this).toggle();
		});
		$('#button_box .create_account_button').each(function(){
			$(this).toggle();
		});
		$('#button_box .create_account_checkout_button').each(function(){
			$(this).toggle();
		});		
		$("#loader").toggle();
		
	}
}
//End ValidationMethods