/*//NEW TEMPLATE*/
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

//Main Menu Start
var main_menu = 
{
	"current_id": null,
	"menu_item_bgcolor": '#ED4E5A',
	"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','');
		$('#shown' + id).css('background',this.menu_item_bgcolor);
	}, 
	
	"menu_close": function (id) 
	{
		if ($('#hidden' + id).length != 0)
		{
			$('#hidden' + id).hide();
		}
		
		$('#shown' + id).css('background','');
		$('#shown' + this.current_id).css('background',this.menu_item_bgcolor);
	},
	
	"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)
	{
		$('#shown' + first_id).css('background',this.menu_item_bgcolor);
		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)
	    }
      }
    );
    //.height(maxH);
   
    
    //$('#left_nav_menu').height($('#center_content').height() + parseInt($('#center_content').css("padding-top")) +  parseInt($('#center_content').css("padding-bottom")))
}

//End Public Pages 3 Columns

//Start ValidationMethods
var validationMethods = 
{
	"validateEmail": function(email)
	{
		var at="@"
		var dot="."
		var lat=email.indexOf(at)
		var lemail=email.length
		var ldot=email.indexOf(dot)
		if (email.indexOf(at)==-1){
		   return false
		}

		if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lemail){
		   return false;
		}

		if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lemail){
		    return false;
		}

		 if (email.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (email.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (email.indexOf(" ")!=-1){
		    return false;
		 }
 		 return true;
	}, 
	
	"validateURL": function(url)
	{
		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');
		});
		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('');
		}
	}, 
	
	"loadingAnimation": function()
	{
		$('#button_box button').each(function(){
			$(this).toggle();
		});
		$('#button_box .reg_button').each(function(){
			$(this).toggle();
		});
		$("#loader").toggle();
		
	}
}
//End ValidationMethods

