// JavaScript Document

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	if (required && !check_input(formField,fieldLabel))
		result = false;
	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
  return result;
}

function check_input(obj,name)
{
	if(!obj.value.length)
	{
		alert('WARNING : Please provide '+name+ ' in the form');
		obj.focus();
		return false;
	}
	return true;
}

function check_date_field(obj,name,value)
{
	if(!obj.value.length || obj.value==value)
	{
		alert('WARNING : Please provide '+name+ ' in the form');
		obj.value='';
		obj.focus();
		return false;
	}
	return true;
}


function check_select(obj,name)
{
	if(!obj.options.selectedIndex)
	{
		alert('WARNING : Please select '+name+ ' from Pop-Down list');
		obj.focus();
		return false;
	}
	return true;
}

function check_radio(obj,name,count)
{
	var flag=0;
	for(var i=0;i<count;i++)
	{
		if(obj[i].checked)
		{
			return true;
		}
	}
	alert('WARNING : Please select '+name);
	obj[0].focus();
	return false;
}

function off(f)
{
	f.designation.disabled=true;
}

function on(f)
{
	f.designation.disabled=false;
}

function flush(f,str)
{
	if(f.value==str)
		f.value='';
	f.focus();
	return false;
}

function show_hide(obj)
{
	var id=document.getElementById(obj);
//	var img=document.getElementById(obj+'_img');
	if(id.className=='show')
	{
		id.className='hide';
//		img.src='/images/collapse.gif';
	}
	else
	{
		id.className='show';
//		img.src='/images/expander.gif';
	}
}
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function toggle_tab(obj)
{
	var arrayTab=Array('Events_Tab','Profile_Tab','News_Tab','Foundation_Tab');
	var id;
	for(var i=0; i<arrayTab.length;i++)
	{
		id=document.getElementById(arrayTab[i]);
		if(obj==arrayTab[i])
			id.className='show';
		else
			id.className='hide';
	}
}
