function showForm(obj) {
		var o = document.getElementById(obj);
		if(o.style.display=='')	o.style.display = 'none';
		else o.style.display = '';
}

function fconfirmdel(str)
{
	if(confirm(str)) {
		return true;
	}
	return false;
}

function CheckEmail(sEMail){
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
	if (sEMail.search(re) == -1){
			return (false);
	}
	else{
		return (true);
	}
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function isDate (day,month,year) {
	var today = new Date();
	year = ((!year) ? y2k(today.getYear()):year);
	month = ((!month) ? today.getMonth():month-1);
	if (!day) return false
	var test = new Date(year,month,day);
	if ( (y2k(test.getYear()) == year) &&
		 (month == test.getMonth()) &&
		 (day == test.getDate()) )
		return true;
	else
		return false
}

function moveOption( source, destination )
{
	objSource = document.getElementById( source );
	objDestination = document.getElementById( destination );

	lengthSource = objSource.options.length;
	arr = new Array();

	for( i = lengthSource - 1; i > 0 ; i-- )
	{
		if( objSource.options[i].selected ){
			lengthDestination = objDestination.options.length;

			text  = objSource.options[ i ].text;
			value = objSource.options[ i ].value;
			title = objSource.options[ i ].title;

			objDestination.options[lengthDestination] = new Option( text, value );
			objDestination.options[lengthDestination].title = title;

			objSource.remove( i );
		}
	}

	sortSelectOption( destination );
}

function sortSelectOption( id, sortOrder )
{
	obj = document.getElementById( id );
	length = obj.options.length;
	arr = new Array();

	for( i = length - 1 ; i > 0 ; i-- )
	{
		option = new Array();
		option[0] = obj.options[i].text;
		option[1] = obj.options[i].value;
		option[2] = obj.options[i].title;
				
		arr[ arr.length ] = option;
		obj.remove( i );
	}
	
	arr.sort();

	for( i = 0 ; i < arr.length ; i++ )
	{
		option = arr[i];
		text = option[0];
		value = option[1];
		title = option[2];

		length = obj.options.length;
		obj.options[ length ] = new Option( text, value );
		obj.options[ length ].title = title;
	}
}

function open_closeDiv(div_id)
{
	div_object	= $(div_id);
	if(div_object.style.display=='')
	{
		div_object.style.display = 'none';
	}else
	{
		div_object.style.display = '';
	}
	
}

function fCheckAll(obj,element) {
    var ml = document.getElementById(obj);
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
		var gtri=e.name.split("[]");
		if (gtri[0] == element) {
		e.checked = true;
	    }
	}
} 

function fCheckStatus (obj,element) {
	var ml = document.getElementById(obj);
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
			var e = ml.elements[i];
			var gtri=e.name.split("[]");
			if (gtri[0] == element) {
				if(e.checked) return true;
	    }
	}
	return false;
}

function fUnCheckAll(obj,element) {
    var ml = document.getElementById(obj);
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
		var gtri=e.name.split("[]");
	    if (gtri[0] == element) {
		e.checked = false;
	    }
	}
	
}


function _checkPhone(st){
var _40="0123456789-+() ";
var _41=trim(st);
if(_41.length<1){
return false;
}
for(i=0;i<_41.length;i++){
ch=_41.charAt(i);
if(_40.indexOf(ch)<0){
return false;
}
}
return true;
}
function checkValidPhone(obj){
var s=trim(obj.value);
if(!_checkPhone(s)){
return false;
}
return true;
}
