
function getDetails(obj){ 
	clickX = obj.offsetLeft; 
	clickY = obj.offsetTop; 
	alert(clickX); 
	alert(clickY);
		var left = document.getElementById('videobar').offsetLeft;
		var width = document.getElementById('leftbar').offsetWidth;
		var barwidth = document.getElementById('videobar').offsetWidth;
		var mouse = event.clientX;
		
		alert("left - " + left + "\nwidth - " + width + "\nBar Width - " + barwidth + "\nPosition - " + mouse);
	}
	
function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false ;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false ;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false ;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false ; 
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false ;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false ;
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false ;
	 }

	 return true ;					
}

function Profilenamechk(str)
{
	var msg = '';
	var alpha = /^[a-z A-Z]+$/;
	if (str.indexOf(" ")!=-1)
	 {
		msg += "Profile name should not contain spaces...\n";
	 }

	if(str.length > 15)
	{
		msg += "Profile name should not have more than 15 characters...\n";

	}
	
	if(str!="")
	{
		if(!str.match(alpha))
		{
			msg += name + " should contain alphabets only...\n" ;
		}
	}
	return msg;
}

function CheckLogin(user,pass)
{
	var Msg = '' ;

	if(user == '')
	{
		Msg += "Username Required...\n" ;
	}
	
	if(pass == '')
	{
		Msg += "Password Required...\n" ;
	}
	
	if(Msg != '')
	{
		alert(Msg) ;
		username.focus() ;
		return false ;
	}
}


function CheckBlank(name,str)
{
	var ErrMsg = '' ;
	var Name = name;
	if(str == '')
	{
		ErrMsg = Name + " Required...\n" ;
	}

	return ErrMsg ;
}


function CheckSame(Name1,Value1,Name2,Value2)
{
	var msg = '';
//alert(Value1,Value2);
	if(Value1 != Value2)
	{
		msg = "Values in '" + Name1 + "' and '" + Name2 + "' are not same.\n" ;
	}
	return msg ;
}

function CountCharacter(Obj,Cnt,ShowObjName) 
{
	//alert(Obj) ;
	var Length = Obj.value.length ;
	var Value = Obj.value ;
	if(Length > Cnt)
	{
	    //alert("Exceed" + Desc.substr(0,200)) ;
		//Med.Desc.value = "" ;
	    Obj.value = Value.substr(0,Cnt) ;
		var Length = Obj.value.length ;
	}
	if(ShowObjName!='')
	{
		ShowObjName.value = parseInt(Length) ;	
	}
    return ;
	//alert(DescLen) 
}

function ShowError(msg)
{
	var Message = '';
	var msg = msg ;
	Message = "Following Errors occured during submission:- \n" + msg;
	alert(Message);
}


function CheckFilename(string)
{
	var ErrMsg = '';
	
    if (string.indexOf('/') > -1)
        filename = string.substring(string.lastIndexOf('/')+1,string.length);
    else
        filename = string.substring(string.lastIndexOf('\\')+1,string.length);
	
	if(filename.match(/^[\w][\w\.\-]{1,32}$/))
		ErrMsg = "";
	else
		ErrMsg = "Invalid Filename... Filename may have spaces.";
	
	return ErrMsg ;
}
function checkalphabet(name,str)
{
	var errmsg = '' ;
	var alpha = /^[a-z A-Z]+$/;
	if(str!="")
	{
		if(!str.match(alpha))
		{
			errmsg =name + " should contain alphabets only...\n" ;
			return errmsg;
		}
		else
		{	
			return errmsg;
		}
	}
	else
			return errmsg;
}

function checknumber(name,str)
{
   var errmsg = '';
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   var numflag = 0;

 
   for (i = 0; i < str.length && IsNumber == true; i++) 
   { 
      Char = str.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
		 IsNumber = false;
         numflag = 1;
      }
   }
	
	if(numflag==1)
	{
		errmsg = name + " Should Contain Numbers Only...\n" ;
	}
	
	return errmsg;
}

function emailcheck(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	var msg='' ;
	var flag=1;
	if (str.indexOf(at)==-1)
	{
		flag=flag && 0;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		flag=flag && 0;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		flag=flag && 0;
	}

	 if (str.indexOf(at,(lat+1))!=-1)
	 {
		flag=flag && 0;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	 {
		flag=flag && 0;
	 }

	 if (str.indexOf(dot,(lat+2))==-1)
	 {
		flag=flag && 0;
	 }
	
	 if (str.indexOf(" ")!=-1)
	 {
		flag=flag && 0;
	 }
	 if(str = '')
	 {
		msg += "Username required...\n";	 
	}
	else if(flag==0 )
 	{
 		msg +="Email is invalid...\n";
	}
 return msg;						
}



function emailcheckContact(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	var msg='' ;
	var flag=1;
	if (str.indexOf(at)==-1)
	{
		flag=flag && 0;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		flag=flag && 0;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		flag=flag && 0;
	}

	 if (str.indexOf(at,(lat+1))!=-1)
	 {
		flag=flag && 0;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	 {
		flag=flag && 0;
	 }

	 if (str.indexOf(dot,(lat+2))==-1)
	 {
		flag=flag && 0;
	 }
	
	 if (str.indexOf(" ")!=-1)
	 {
		flag=flag && 0;
	 }
	 if(str = '')
	 {
		msg += "Username required...\n";	 
	}
 if(flag==0 )
 	{
 		msg +="Email is invalid...\n";
	}
 return msg;						
}


function Check(form)
{
	var flag="";
	var i= 0
	for (; i < form.elements.length; i++)
	{
		var form_element = form.elements[i];
		
		if(form_element.type =="checkbox")
		{
			if (form_element.checked== true) 
			{
				flag="";
				break;
			}
			else
				flag="Select Atleast One CheckBox...\n";
		}
	}
	return flag;
}

function CheckALL(form,ALL_checkbox)
{

// This function iterates through all checkboxes in a form and if the checkbox named 'allbox' is checked,
// then it will check each individual checkbox. Otherwise if 'allbox' is unchecked, then it will uncheck
// each indivudual checkbox.
	
	for (i=0; i < form.elements.length; i++)
	{
		var form_element = form.elements[i];
		
		if ((form_element.name != 'allbox') && (form_element.type == 'checkbox'))
		{
			if (ALL_checkbox != 1) // If the ALL checkbox is OFF, set all checkboxes to OFF (and vice-versa)
				form_element.checked = form.allbox.checked;
		}
	}
}
	
function CheckboxCheck(form)
{

// This function iterates through all checkboxes in a form and counts up the total number of checkboxes,
// and the total number of those checkboxes that are checked (not including the 'allbox'). If they are equal,
// then the checkbox named 'allbox' is then checked, otherwise 'allbox' is unchecked.

	var total_checkboxes = 0;
	var checked_checkboxes = 0;
	
	for (i=0; i < form.elements.length; i++)
	{
		var form_element = form.elements[i];
		if ((form_element.name != 'allbox') && (form_element.type == 'checkbox'))
		{
			total_checkboxes++; // If the form element is a checkbox and it's not the 'ALL' checkbox, increment the total_checkboxes counter
			if (form_element.checked)
				checked_checkboxes++; // If the checkbox we're on is checked, add it to the checked_checkboxes total
		}
	}
	
	// If the total number of checkboxes checked equals the total number of checkboxes, put a check
	// in the ALL checkbox. Otherwise don't put a check in the ALL checkbox
	
	form.allbox.checked = (checked_checkboxes == total_checkboxes) ? true : false; 
}
function CheckAll(chkbox, form)
{
	var f,len ;
	f = form;
	
	len = f.elements.length;
	
	for(i=0;i<len;i++)
	{
		if(f.elements[i].type == 'checkbox')
		{
			if(chkbox.checked == true)
			{
				f.elements[i].checked = true;
			}
			else if(chkbox.checked == false)
			{
				f.elements[i].checked = false;
			}
		}
	}	
}