﻿// hello

(function($) {

	$.fn.customFadeIn = function(speed, callback) {

		$(this).fadeIn(speed, function() {

			if(jQuery.browser.msie)

				$(this).get(0).style.removeAttribute('filter');

			if(callback != undefined)

				callback();

		});

	};

	$.fn.customFadeOut = function(speed, callback) {

		$(this).fadeOut(speed, function() {

			if(jQuery.browser.msie)

				$(this).get(0).style.removeAttribute('filter');

			if(callback != undefined)

				callback();

		});

	};

})(jQuery);


function displayError ( formNode , validators )

{
	$ ( '#errorDisplay').opacity=0;
	$ ( '#errorDisplay').css ( 'display','none' );
	
	
    var errorHTML = "";

    for(var i=0;i<validators.length;i++){

        errorHTML += "<li>" + validators[i].message + "</li>";

    }

    $ ( '#errorDisplay').customFadeIn ( "normal" );

    $ ('#errorDisplay').html ( "<h4>Please correct the following problems</h4><ul style='margin-top:5px'>" + errorHTML + "</ul>" );  

}

function displayErrorAdditional ( message )

{
	$ ( '#errorDisplay').opacity=0;
	$ ( '#errorDisplay').css ( 'display','none' );

    $ ( '#errorDisplay').customFadeIn ( "normal" );

    if ( $('#errorDisplay').html().indexOf ( message ) == -1 ) 

        $ ('#errorDisplay').html ( "<h4>Please correct the following problems</h4><ul style='margin-top:5px'><li>" + message + "</li></ul>" );  

}

function displayMessage ( message )
{
	
	$(window).load(function () {
$ ( '#errorDisplay').opacity=0;
	$ ( '#errorDisplay').css ( 'display','none' );
	$ ( '#errorDisplay').css ( 'border','solid 1px #efefef' );
	$ ( '#errorDisplay').css ( 'padding','10px	' );
		
		$ ( '#errorDisplay').customFadeIn ( "normal" );
		if ( $('#errorDisplay').html().indexOf ( message ) == -1 ) 
			$ ('#errorDisplay').html ( "<h4>" + message + "</h4>" );  
	} );
}



// This will be triggered by the tmt:defaultvalue attribute
tmt_globalRules.defaultvalue = function(fieldNode){
	if (fieldNode.getAttribute("tmt:defaultvalue") == fieldNode.value)
	{
		return false;
	}
	else if (fieldNode.value == "")
	{
		return false;
	}
	else
	{
		return true;
	}
}

tmt_globalRules.sessionsvalidate = function(fieldNode){
	var divContainer = fieldNode.getAttribute("tmt:sessionsvalidate");
	
	if ($("#" + divContainer + " input[type='radio']:checked").length == 0)
	{
		return false;
	}
	else
	{	
		return true;
	}
}
