

function SetAllCheckBoxes(FormName, FieldName)
{
	if(document.getElementById('checkall').checked==true)
	{
	var CheckValue = true;

	}
	else
	{
		var CheckValue = false;
	
	}
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function loadpage(page)
{
	Lightview.show({
		href: page,
		rel: 'ajax',
		options: {
			autosize: true,
			topclose: true,
			ajax: {
				onComplete: function(){
				// once the request is complete we observe the form for a submit
				$('ajaxForm').observe('submit', submitAjaxFormDemonstration);
				}
			}
		}
	});
	
	
}


function showform(id)
{
	var id = "#"+id;
	$(id).fadeIn(200);
	
}
function hideform(id)
{
	var id = "#"+id;
	$(id).fadeOut(200);
}


function goto(url,ask,msg)
{
	if(ask==true)
	{
		if(confirm(msg) )
		{
			window.location=url;
		}
	}
	else
	{
		window.location=url;
	}
}

function goback()
{
	history.go(-1)	;
}

function del(url)
{
	if(	confirm("Are you sure you want to delete it?") )
	{
		window.location=url;
	}
}




function checkusername(field)
{
	var fi = "#"+field;
	$("#msgbox").removeClass().addClass('textfieldInvalidFormatMsg').text('Validating....').fadeIn(200);
	$.post("ajax.php",{action:'checkusername',email:$(fi).val()}, function(data)
		{
			$("#uav").val(data);	
			if(data=="0")
			{
				$("#msgbox").removeClass().addClass('textfieldInvalidFormatMsg').text('Email address not available').fadeIn(200);
				

			}
			else 
			{
				$("#msgbox").removeClass().addClass('messageboxok').text('Email address is available').fadeIn(200);
				
			
			}
	
		})	;


}


function formvalid()
{
	checkusername();
	var valid = false;
	if($("#uav").val()==0)	
	{
		valid = false;	
	}
	else if($("#pass").val()!=$("#cpass").val())
	{
		alert("Confirm password mismatch");
		valid =  false	;
	}											  
	else
	{
		valid =  true;	
	}
return valid ;
	
}