// JavaScript Document
var tr;
function changeLinkCss(upperTab,upperLink,leftMenuTr,LeftMenuLink)
{
if(upperTab!=0)
 	document.getElementById(upperTab).className='linkboldtext1';
 if(upperLink!=0)
 	document.getElementById(upperLink).className='linkboldtext1';
 if(leftMenuTr!=0)
 	document.getElementById(leftMenuTr).className='currentlink';
 if(LeftMenuLink!=0)
 	document.getElementById(LeftMenuLink).className='currentlink';
 tr = leftMenuTr;
}
function showHideTab(tabId)
{
  hideRow("tabHome");
  hideRow("tabComp");
  hideRow("tabUserM");
  hideRow("tabEvents");
  hideRow("tabQuestion");
  hideRow("tabSetting");
  hideRow("tabReport");
  hideRow("tabEventsAll");
  showRow(tabId);
}

function onMouseOver1(id,lnk)
{
if(id!=0 && id!=tr)
 document.getElementById(id).bgColor="#FFFFFF";
}

function onMouseOut1(id,lnk)
{
if(id!=0 && id!=tr)
  document.getElementById(id).bgColor="#EAF1F9";
}

function openBlock(ctlId,ele){
//alert(document.getElementById(ctlId).style.display);
//alert(document.getElementById(ctlId + 'Close').style.display);

if( document.getElementById(ctlId).style.display == "none"){	
	document.getElementById(ctlId).style.display = ""
	document.getElementById(ctlId + 'Close').style.display = "none"; 
}else if(document.getElementById(ctlId).style.display == ""){

	document.getElementById(ctlId).style.display = "none"
	document.getElementById(ctlId + 'Close').style.display = ""; 
}
}

function Trim(str)
{ 
while(str.charAt(0) == (" ") )
{ str = str.substring(1);
}

while(str.charAt(str.length-1) == " " )
{ str = str.substring(0,str.length-1);
}
return str;
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	
 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 checkURL(value) {
var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)"); 
//RegExp("^www.([0-9A-Za-z]+\.)");

if(urlregex.test(value))
{
return true;
}
return false; 
}

function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function isURL(urlStr){
/* if (urlStr.indexOf(" ")!=-1){
  alert("Spaces are not allowed in a URL");
  return false;
 }
 if(urlStr==""||urlStr==null){
  return false;
 }
 urlStr=urlStr.toLowerCase();
 var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 var validChars="\[^\\s" + specialChars + "\]";
 var atom=validChars + '+';
 //var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
 var urlPat=/^http:\/\/.([\-\+a-z0-9]*)\.(\w*)/;
 //var urlPat=/^http:\/\/(\w*)\.([\_\-\+a-z0-9]*)\.(\w*)/; // if underscore(_) is also needed.
 var matchArray=urlStr.match(urlPat);

 if (matchArray==null){
  alert("Please Enter Valid URL");
  return false;
 }*/
 /*
 var user=matchArray[2];
 var domain=matchArray[3];
 for (i=0; i<user.length; i++) {
  if (user.charCodeAt(i)>127) {
   alert("This domain contains invalid characters.");
   return false;
  }
 }
 for (i=0; i<domain.length; i++) {
  if (domain.charCodeAt(i)>127) {
   alert("This domain name contains invalid characters.");
   return false;
  }
 }
 var atomPat=new RegExp("^" + atom + "$");
 var domArr=domain.split(".");
 var len=domArr.length;
 for (i=0;i<len;i++) {
  if (domArr[i].search(atomPat)==-1) {
   alert("The domain name does not seem to be valid.");
   return false;
  }
 }
 if (domArr[domArr.length-1].length<2 && domArr[domArr.length-1].search(urlStr)==-1) {
  alert("The address must end in a well-known domain or two letter " + "country.");
  return false;
 }
*/
 return true;
 }
 
 
function rowOverEffect(object) {

  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function checkdele(del,chkname)
{

	if(del == "1")
	{
		var ele;		
		ele = document.getElementsByName(chkname);
		chkflag = false;
		for(i=0;i<ele.length;i++)
		{
				if(ele[i].checked)
				{
					 chkflag = true;
					 break;
				}
		}
		if(chkflag == true)
		flag = 	confirm("Are you sure you want to delete selected records?");
		else{
			alert("Please select atleast one record to delete.");
			return false;
		}
			
	}
	else
	{
		flag = 	confirm("Are you sure you want to delete this record?");
	}
	if(flag == false)
	return false;
}
