﻿/* UI scripts */

// Uses http://jQuery.com

$(function(){
    $('.con-header-1 .mod-login fieldset').addClass('js');
    $('.con-header-1 label.overlabel').overlabel();
});

// Show/hide header login form (only if validation message is hidden)

// Called by onclick on img in Login header
function closeValidationSummary(){
	$("#ctl00_lgnLogin_vdsSummary").fadeOut();
}

function SetErrorClass(containerid)
{
    var blnIsValid;
    var controlid;
    //Page_ClientValidate();
    $(document).ready(function() {
        $("body").find("#" + containerid + " .validator")
        //$("body").find(".validator")
            .each(function(){
		        validator = document.getElementById($(this).attr('id'));
		        ValidatorValidate(validator);
		        var newblnIsValid = validator.isvalid;
		        var newcontrolid = validator.controltovalidate;
		        
		        //alert(validator.id + ' ' + validator.isvalid);
		        if (!newblnIsValid)
			        $(this).parents("div:first").addClass("error").end();
			    else if (newblnIsValid && ((controlid==newcontrolid && blnIsValid) || controlid!=newcontrolid))
			        $(this).parents("div:first").removeClass("error").end();
			    
			    if (controlid == newcontrolid)
			    {
			        if (!blnIsValid || !newblnIsValid)
			            blnIsValid = false;
			    }   
			    else
			    {
			        controlid = newcontrolid;
			        blnIsValid = newblnIsValid;
			    } 
	        })
    });
}

/* used for CustomValidators to check the length of text areas */
function ValidateMaxLength1000(sender, args)
{
    //alert('ValidateMaxLength1000 ' + args.Value.length);
	if (args.Value.length > 1000)
	{
		args.IsValid = false;
	}
	else 
	{
	    args.IsValid = true;
	}
}

function ValidateMaxLength4500(sender, args)
{
    //alert('ValidateMaxLength1000 ' + args.Value.length);
	if (args.Value.length > 4500)
	{
		args.IsValid = false;
	}
	else 
	{
	    args.IsValid = true;
	}
}

function ValidateMaxLength5000(sender, args)
{
    //alert('ValidateMaxLength5000 ' + args.Value.length);
	if (args.Value.length > 5000)
	{
		args.IsValid = false;
	}
	else 
	{
	    args.IsValid = true;
	}
}

