// history.forward();
// call this function to ignore any event in the parent 
// window when the child window is open.
function childWindowExists(e){
	//e.
}
// call this function on body key press event to close the window on pressing esc key.
function escKeyCloseWindow(e){
	if(e.keyCode == 27)
		window.close();
}

function RefreshParentWindow()
{
	var parentObject;
	parentObject = window.parent
	if (parentObject != null)
	{	
		var hdnIsAnswered = window.parent.document.getElementById("hdnIsAnswered");
		if (hdnIsAnswered != null)
		{
			hdnIsAnswered.value = "1";
		}
	}
}
function CloseWindow()
{
	window.opener.document.forms[0].submit();
	window.close();
}

// Function to validate maxlength of textarea
function validateLength(controlName, maxLength)
{
	var myValue=controlName.value;
	if(myValue.length > maxLength)
	{
		return false;
	}
	return true;
}

function writeStatusBarMessage()
{
    window.status = statusMessage;
    return true;
}

function hideStatusBarMessage()
{
    window.status = '';
    return true;
}

sortitems = 1;  // Automatically sort items within lists? (1 or 0)

function moveAll(fbox, tbox) 
{
	for(var i=0; i<fbox.options.length; i++) 
	{
		if(fbox.options[i].value != "0") 
		{
			var no = new Option();
			no.value = fbox.options[i].value;
			no.text = fbox.options[i].text;
			tbox.options[tbox.options.length] = no;
			fbox.options[i].value = "";
			fbox.options[i].text = "";
		}
	}
	BumpUp(fbox);
	if (sortitems) SortD(tbox);
}

		function Trim(s) 
		{
			// Remove leading spaces and carriage returns
  
			while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
			{
				s = s.substring(1,s.length);
			}

			// Remove trailing spaces and carriage returns

			while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
			{
				s = s.substring(0,s.length-1);
			}
			return s;
		}

function addfromtxt(txtbox, tbox,flag) 
{		
	if(Trim(txtbox.value)=="")
	{
		alert("Please enter a value");
	}
	else
	{
//		var no = new Option();
//		no.text = Trim(txtbox.value);
//		no.value = Trim(txtbox.value);	
//		tbox.options[tbox.options.length] = no;
//		txtbox.value = "";
		checkAndAdd("","",txtbox,tbox,flag)
	}
	if (sortitems) SortD(tbox);	
}





//Flag: indicates the type of entry
function checkAndAdd(i,fbox,txtbox,tbox,flag)
{
	var bln = 0;
	for(var j=0; j<tbox.options.length; j++) 
	{	
		if(txtbox == "")	
		{
			if(fbox.options[i].text == tbox.options[j].text)
			{
				bln = 1;	
			}
		}
		else
		{
			if(txtbox.value == tbox.options[j].text)
			{				
				bln = 1;				
			}
		}
	}
	if (bln == 0)
	{
		var no = new Option();
		if(txtbox == "")	
		{
			no.text = fbox.options[i].text;
			no.value = fbox.options[i].value;			
		}
		else
		{
			no.text = Trim(txtbox.value);
			no.value = Trim(txtbox.value);
			txtbox.value = "";					
		}
		tbox.options[tbox.options.length] = no;		
	}
	else
	{		
		if(txtbox == "")	
		{
			alert("This area of expertise is already selected. Please select another one");			
		}
		else
		{
			if (flag == 1)
			{
				alert("The entered area of expertise is already selected. Please enter another one");
			}
			else
			if (flag == 2)
			{
				alert("The entered published article is already selected. Please enter another one");
			}
			if (flag == 3)
			{
				alert("The entered professional certification is already selected. Please enter another one");
			}
			else
			if (flag == 4)
			{
				alert("The entered professional license is already selected. Please enter another one");
			}
			else
			if (flag == 5)
			{
				alert("The entered award/achievement is already selected. Please enter another one");
			}	
			txtbox.value = "";
			txtbox.focus();
		}		
	}
}

function addinto(fbox, txtbox, tbox) 
{	
	if(Trim(txtbox.value)=="")
	{
		for(var i=0; i<fbox.options.length; i++) 
		{		
			if(fbox.options[i].selected) 
			{
				checkAndAdd(i,fbox,"",tbox,'1');
			}
		}
	}
	else
	{
		checkAndAdd("","",txtbox,tbox,'1');		
	}	
	if (sortitems) SortD(tbox);	
}

function removefrom(fbox) 
{	
	for(var i=0; i<fbox.options.length; i++) 
	{		
		if(fbox.options[i].selected) 
		{			
			fbox.options[i].text = "";
			fbox.options[i].value = "";
		}
	}
	BumpUp(fbox);	
	if (sortitems) SortD(fbox);	
}

function move(fbox, tbox) 
{
	for(var i=0; i<fbox.options.length; i++) 
	{
		var theform = document.forms[0];
		if(fbox.options[i].selected && fbox.options[i].value != "0") 
		{
			var no = new Option();
			no.value = fbox.options[i].value;
			no.text = fbox.options[i].text;			
			tbox.options[tbox.options.length] = no;
			fbox.options[i].value = "";
			fbox.options[i].text = "";
		}
	}
	BumpUp(fbox);
	if (sortitems) SortD(tbox);	
}


function moveOrganizationsToHidden()
{
	var theform = document.forms[0];	
   	theform.hdnAssignedOrganizations.value = "";
	for(var i=0; i<theform.lbxAssignedOrganizations.options.length; i++) 
	{
		if(theform.hdnAssignedOrganizations.value == "")
		{
			theform.hdnAssignedOrganizations.value = theform.lbxAssignedOrganizations.options[i].value;
		}	
		else
		{
			theform.hdnAssignedOrganizations.value = theform.hdnAssignedOrganizations.value + "," + theform.lbxAssignedOrganizations.options[i].value;
		}	
	}
	if (theform.rbtnListAssociationCriteria[0].checked == true)
	{
		if (theform.hdnAssignedOrganizations.value == "")
		{
			alert("Please select organization(s) for association/disassociation");
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}


function BumpUp(box)  
{
	for(var i=0; i<box.options.length; i++) 
	{
		if(box.options[i].value == "")  
		{
			for(var j=i; j<box.options.length-1; j++)  
			{
				box.options[j].selected = false;
				box.options[j].value = box.options[j+1].value;
				box.options[j].text = box.options[j+1].text;
			}
			var ln = i;
			break;
		}
	}
	if(ln < box.options.length)  
	{
		box.options.length -= 1;
		BumpUp(box);
	}
}

function SortD(box)  
{
	var temp_opts = new Array();
	var temp = new Object();
	for(var i=0; i<box.options.length; i++)  
	{
		temp_opts[i] = box.options[i];
	}
	for(var x=0; x<temp_opts.length-1; x++)  
	{
		for(var y=(x+1); y<temp_opts.length; y++)  
		{
			if(temp_opts[x].text > temp_opts[y].text)  
			{
				temp = temp_opts[x].text;
				temp_opts[x].text = temp_opts[y].text;
				temp_opts[y].text = temp;
			}
		}
	}

	for(var i=0; i<box.options.length; i++)  
	{
		box.options[i].value = temp_opts[i].value;
		box.options[i].text = temp_opts[i].text;
	}
}

/*
0 if the dates are same 
-1 if the first one is an earlier date 
1 if the first one is a later date 
*/
function compareDates (value1, value2) {
   var date1, date2;
   var month1, month2;
   var year1, year2;
   var dateseperator = "/";
   
   date1 = convertToInt(value1.substring (0, value1.indexOf (dateseperator)));
   month1 = convertToInt(value1.substring (value1.indexOf (dateseperator)+1, value1.lastIndexOf (dateseperator)));
   year1 = convertToInt(value1.substring (value1.lastIndexOf (dateseperator)+1, value1.length));

   date2 = convertToInt(value2.substring (0, value2.indexOf (dateseperator)));
   month2 = convertToInt(value2.substring (value2.indexOf (dateseperator)+1, value2.lastIndexOf (dateseperator)));
   year2 = convertToInt(value2.substring (value2.lastIndexOf (dateseperator)+1, value2.length));

   if (year1 > year2) return 1;
   else if (year1 < year2) return -1;
   else if (month1 > month2) return 1;
   else if (month1 < month2) return -1;
   else if (date1 > date2) return 1;
   else if (date1 < date2) return -1;
   else return 0;
} 

function getCurrentDate(){
	var date=new Date();
	var sDate;
	sDate = date.getDate() + "/" + (date.getMonth()+1) + "/" + date.getFullYear(); 		
	return sDate;
}

function ValidateRequiredFieldTextBox(txt, alertMessage, trimValueBeforeValidating){
	if( (txt == null) || (txt == 'undefined') ){
		alert("Undefined text control!");
		return true;
	}
	var val = txt.value;
	if(trimValueBeforeValidating){
		var val = TrimString(val);
		txt.value = val;
	}
	if(val == ""){
		alert(alertMessage);
		txt.focus();
		return false;
	}
	return true;
}

function ValidateIntegerFieldTextBox(txt, minValue, maxValue, emptyFieldMessage, invalidValueMessage, trimValueBeforeValidating){
	if( (txt == null) || (txt == 'undefined') ){
		alert("Undefined text control!");
		return true;
	}
	var val = txt.value;
	if(trimValueBeforeValidating){
		var val = TrimString(val);
		txt.value = val;
	}
	if(val == ""){
		alert(emptyFieldMessage);
		txt.focus();
		return false;
	}
	if(isNaN(val)){
		alert(invalidValueMessage);
		txt.focus();
		return false;
	}
	if(val < minValue){
		alert("Value should be at least " + minValue + "!");
		txt.focus();
		return false;
	}
	if(val > maxValue){
		alert("Value should be less than " + maxValue + "!");
		txt.focus();
		return false;
	}
	return true;
}

function ValidateDecimalFieldTextBox(txt, minValue, maxValue, emptyFieldMessage, invalidValueMessage, minValueMessage, maxValueMessage, trimValueBeforeValidating){
	if( (txt == null) || (txt == 'undefined') ){
		alert("Undefined text control!");
		return true;
	}
	var val = txt.value;
	if(trimValueBeforeValidating){
		var val = TrimString(val);
		txt.value = val;
	}
	if(val == ""){
		alert(emptyFieldMessage);
		txt.focus();
		return false;
	}
	if(!IsDecimal(val)){
		alert(invalidValueMessage);
		txt.focus();
		return false;
	}
	if(val < minValue){
		alert(minValueMessage);
		txt.focus();
		return false;
	}
	if(val > maxValue){
		alert(maxValueMessage);
		txt.focus();
		return false;
	}
	return true;
}

function setFocus(ctl)
{
	if( (ctl != null) && (ctl != 'undefined') )
	{
		ctl.focus();		
	}
	return false;
}

/*String Trim Function*/
function TrimString(str)
{
	var len,x,y;
	var ltrimstr,newstr;
	var flag1 = false
	var flag2 = false
	ltrimstr = "";
	len = str.length;
	for(x=0;x<len;x++){
		if ((str.substr(x,1)!=" ") || (flag1)){
			flag1 = true;
			ltrimstr = ltrimstr + str.substr(x,1);
		}
	}
	newstr = ltrimstr
	for(y=ltrimstr.length-1;y>0;y--){
		if ((ltrimstr.substr(y,1)==" ") && (flag2==false)){				
			newstr = ltrimstr.substr(0,y)
		}
		else
		{
			flag2 =true;
		}
	}

	return newstr;

}

/*This method and variable are used to identify if the user 
has updated any field in the datagrid so that he can be told 
to update the datagrid values so that correct values are sent
into database */
var isDataChanged = false;
function dataChanged(){
	isDataChanged = true;
}

/*
Need to include following line of html code in the parent page
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="cleanup()"></PUBLIC:ATTACH>
*/
/*Pops up new window*/
var OpenWin;
function WindowPopUp(page, windowname, dimension, coord) {
	OpenWin = this.open(page, windowname, "status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes," + dimension + ", " + coord);
	if ((document.window != null) && (!OpenWin.opener))
		OpenWin.opener = document.window;
	OpenWin.focus();
	OpenWin.opener.name="pop"
	document.body.attachEvent("onkeydown", showChildWindow);
	document.body.attachEvent("onmouseup", showChildWindow);
	OpenWin.attachEvent("onunload", hideChildWindow);
}

// On close of child window detach the onkeydown and onmouseup events.
function hideChildWindow(){
	document.body.detachEvent("onkeydown", showChildWindow);
	document.body.detachEvent("onmouseup", showChildWindow)
}

// if the child window is open, then dont let the user work in 
// child window.
function showChildWindow(){
	OpenWin.focus();
	event.returnValue = false;
}

function WindowShowDialog(page, dimension, coord) {
	var returnValue;
	returnValue = this.showModalDialog(page, "", "toolbar=no,menubar=no,location=no,scrollbars=yes,resize=yes," + dimension + ", " + coord);
}

function closeWin() {
	if(OpenWin != null){
		OpenWin.close();
    }
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function IsDecimal(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}

/*
returns 0 if both are equal
returns -1 if d1 is less than d2
returns 1 if d2 is less than d1
*/
function compareDecimals(d1, d2)
{	
	
	var d1 = parseFloat(d1);
	var d2 = parseFloat(d2);
	if (d1 < d2){
		return -1;
	}
	else if (d2 < d1){
		return 1;
	}
	else{
		return 0;
	}
}

// this function converts string to integer
// reason for this besides having parseInt because
// parseInt("08") = 0, which is wrong.
function convertToInt(val){
	var len = val.length;
	var valcopy = val;
	for (var i=0; i < len - 1; i++){
		if(valcopy.substring(i, i + 1) == "0"){
			val = valcopy.substring(i + 1, len);
		}else{
			break;
		}
	}
	return parseInt(val);
}


//to validate invalid characters in name
function SpecialCharecter(a)
{
	var ab=a;
	for(x=0;x<ab.length;x++)
	{	
		a=ab.charAt(x);
		if((a=="!") || (a=="@") || (a=="#") || (a=="$") || (a=="%") || (a=="^") || (a=="&") || (a=="*") || (a=="("))
		{
			return true;
		}
		else if ((a==":") || (a==";") || (a=='"') || (a=="'") || (a=="<") || (a==",") || (a==">") || (a=="?") || (a=="/")||(a=="`"))
		{
			return true;
		}
		else if((a==="{") || (a==="}") || (a==")") || (a=="_") || (a==".") || (a==="=") || (a=="|") || (a=='[')|| (a=='~')||(a==']'))
		{
			return true;
		}
		
	}
	
return false;
}

function spacecheck(a)
{
	var ab=a;
	for(x=0;x<ab.length;x++)
	{	
		a=ab.charAt(x);
		if(a==" ")
		{
			return true;
		}
	}
}


function ValidateGridTextBox(txt, alertMessage, trimValueBeforeValidating)
{
	if( (txt == null) || (txt == 'undefined') ){
		//alert("Undefined text control!");
		return true;
	}
	var val = txt.value;
	if(trimValueBeforeValidating)
	{
		var val = TrimString(val);
		txt.value = val;
	}
	if(val == "")
	{
		alert(alertMessage);
		txt.focus();
		return false;
	}
	return true;
}

function ValidateGridTextBox(txt, alertMessage, trimValueBeforeValidating)
{
	
	if((txt != null) || (txt != 'undefined'))
	{
		var val = txt.value;
		if(trimValueBeforeValidating)
		{
			var val = TrimString(val);
			txt.value = val;
		}
		if(val == "" || val == 0)
		{
			alert(alertMessage);
			txt.focus();
			return false;
		}
		
	 }
	 return true;
}

function ValidateDecimalGridTextBox(txt, alertMessage,invalidValueMessage, trimValueBeforeValidating)
{
	
	if((txt != null) || (txt != 'undefined'))
	{
		var val = txt.value;
		if(trimValueBeforeValidating)
		{
			var val = TrimString(val);
			txt.value = val;
		}
		if(val == "")
		{
			alert(alertMessage);
			txt.focus();
			return false;
		}
		if(!IsDecimal(val))
		{
			alert(invalidValueMessage);
			txt.focus();
			return false;
		}
		
	}
	return true;
}

function ValidateCurrentDate(txt,EmptyFieldAlertMessage,invalidEntryAlertMessage, trimValueBeforeValidating)
{
	
	// To Validate the date field,it Should not be greater than the current date
	var val =txt.value;
	var date=new Date();
	var sDate = getCurrentDate();
	
	if(trimValueBeforeValidating)
	{
		var val = TrimString(val);
		txt.value = val;
	}
	if(val == "")
	{
		alert(EmptyFieldAlertMessage);
		txt.focus();
		return false;
	}
	if (val != null)
	{
		var retCompare = compareDates(val ,sDate);
		if (retCompare==1)
		{ 
			alert(invalidEntryAlertMessage);
			val = "";
			return false;
		}
	}
	return true;
		
}

function ValidateSelectedTextBox(chkBox,txtBox,alertMessage, trimValueBeforeValidating)
{
	if(chkBox.checked==true)
	{
		if( (txtBox == null) || (txtBox == 'undefined') )
		{
			alert("Undefined text control!");
			return true;
		}
		var val = txtBox.value;
		var valchk=chkBox.checked
			
		if(trimValueBeforeValidating)
		{
			var val = TrimString(val);
			txtBox.value = val;
		}
		if((val == "") && (valchk==true))
		{
			alert(alertMessage);
			txtBox.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
	 return true;
	}
} 



// this function checks the zip code.
function checkZipCode(txtField)
{

 var valid ="1234567890";
 var ok = "yes";
 var temp;
 
 if(txtField.value.length != 5)
  {
	return false;
  }
 
  for(var i=0;i<txtField.value.length;i++)
  {
     	temp = "" + txtField.value.substring(i, i+1);
	if (valid.indexOf(temp) =="-1") 
	{
		ok = "no";
		break;
	}
  }

  if(ok=="no") return false;

  return true;
}

		function Trim(s) 
		{
			// Remove leading spaces and carriage returns
  
			while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
			{
				s = s.substring(1,s.length);
			}

			// Remove trailing spaces and carriage returns

			while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
			{
				s = s.substring(0,s.length-1);
			}
			return s;
	}		


////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////// email checking /////////////////////////////////////////////////

// Validate E-mail Address

special = new Array("`","~","!","#","$","%","^","&","*","(",")","=","+","|","{","}","[","]",":",";","'","\"","<",">","/"," ");


function validEmail(field)
	 {
	  var str = field.value;
      var str= new String(str);
      str= str.toLowerCase();
      var k= str.length;
      var ch=new String("");

      /* validate initially not presence of the dot */

		if (str.indexOf(".") < 1 )
		{
		return true;
		}

      var chr = str.substring(0,1);

      for(var i = 0; i < str.length; i++)
		{
	  		var chr = str.substring(i, i + 1);
			for(var j =0; j < special.length;j++)
			{

 			   if(chr==special[j])
 			   {
			    return true;
			    }
 		    }
        }



        if(k!=0)
        {
         if(k<6)
         {
         return true;
         }
         else
         {
 	      for(var j=k-1;j>=0;j--)
   	      {
            ch=ch.concat(new String(str.charAt(j)));}
            var tmp=ch.indexOf("@");
             if(tmp<0)
             {
			 return true;
			 }
             else
             {
		     tmp=ch.indexOf("@",tmp+1);
      		   if(tmp>0)
         	   {
			   return true;
               }
                var indx=ch.indexOf(".");
		        if((indx!=2) && (indx!=3))
                {
				return true;
                }
                var chk=ch.indexOf("@");
				var lindx=ch.lastIndexOf(".");

				 if(lindx==-1)
				 {
				 return true;
               	 }
                 else
				 {
            	 var ldx = ch.lastIndexOf(".",lindx-1);
				     if(ldx != -1)
				 	 {
				   	 lindx=ldx;
               		 }
		         	 else
				     {
					 lindx=0;
					 }

		 		 while( indx <= lindx )
               		 {
					    if( (ch.charAt(indx-1) == ".") ||  (ch.charAt(indx+1) == ".") )
                  	    {
						 return true;
                        }
                   		indx=ch.indexOf(".",indx+1);
                   		}
                     }

		             if( (ch.charAt(chk+1) == "")||(ch.charAt(chk+1) == ".") ||
      		         (ch.charAt(chk-1) == ".")||(ch.charAt(chk-1) == "") )
            	     {
					 return true;
                     }
                 }
           }
     }
 return false;
}


function checkGUID(txtObj) {
  var re = new RegExp("\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}");
  if (txtObj.value.match(re)) {
    return true;
  } else {
    return false;
  }
}
function CheckUploadImage(file)
{
	if (file != "")
	{
		var ext = file.substring(file.lastIndexOf(".")+1);					
		var ext=ext.toLowerCase();
		if (	ext == "gif"	|| 
				ext == "jpeg"	|| 
				ext == "jpg"	|| 
				ext == "tif"	|| 
				ext == "tiff"	|| 
				ext == "png"	|| 
				ext == "bmp")
		{
				return true;								
		}
		else
		{
				alert("Invalid file format.\nThe acceptable file formats are .gif, .jpg , .jpeg , .tif , .tiff , .png or .bmp .");
				return false;
		}
	}
	return true;
}

function CheckUploadVideo(file)
{
	if (file != "")
	{
		var ext = file.substring(file.lastIndexOf(".")+1);					
		if ( ext == "avi" || ext == "mpg" || ext == "mov" || ext =="mpeg" || ext =="wmv" )
		{
				return true;								
		}
		else
		{
				alert("Invalid file format.The acceptable file formats are .avi .mov .wmv .mpg or .mpeg .");
				return false;
		}
	}
	return true;
}
function CheckUploadSound(file)
{
	if (file != "")
	{
		var ext = file.substring(file.lastIndexOf(".")+1);
		if ( ext == "wav" || ext == "mid" || ext == "midi" || ext == "wma" || ext == "mp3")
		{
				return true;								
		}
		else
		{
				alert("Invalid file format.The acceptable file formats are .wav, .mid, .midi, .wma or .mp3 .");
				return false;
		}
	}
	return true;
}
function clickIE4()
{
	if (event.button==2)
	{
		return false;
	}
}
function clickNS4(e)
{
	if (document.layers||document.getElementById&&!document.all)
	{
		if (e.which==2||e.which==3)
		{
			return false;
		}
	}
}
function DisableRightClick()
{
	if (document.layers)
	{
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS4;
	}
	else if (document.all&&!document.getElementById)
	{
		document.onmousedown=clickIE4;
	}
	document.oncontextmenu=  new Function("return false");	
}
//added on may15th 2006
//check for Letter		
function IsLetter (sText)
{
	var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. ";
	var isletter=true;
	var Char;
	for (i=0;i<sText.length && isletter==true;i++) 
	{ 
		Char = sText.charAt(i); 
		if (valid.indexOf(Char) == -1) 
		{
		isletter = false;
		}
	}
	return isletter;
}
	
//check for number	
function IsNumber(sText)
{  
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
	Char = sText.charAt(i); 
	if (ValidChars.indexOf(Char) == -1) 
	{
	IsNumber = false;
	}
	}
	return IsNumber;
}
							//check for number	
function IsAlphaNumeric(sText)
{  
	var ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. ";
	var isAphaNumeric=true;
	var Char;

	for (i = 0; i < sText.length && isAphaNumeric == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			isAphaNumeric = false;
		}
	}
	return isAphaNumeric;
}
//ends here
function DisableActivexMessage(orgBanner)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
	document.write(' width="517" height="77" VIEWASTEXT> <param name="movie" value="' + orgBanner + '" > ');
	document.write(' <param name="quality" value="high"> <embed quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.write(' type="application/x-shockwave-flash" width="517" height="77" src="' + orgBanner + '"></embed></object>');
}
function DisableActivexMessageforChannelHeader(orgBanner)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
	document.write('width="800" height="72" VIEWASTEXT> <param name="movie" value="' + orgBanner + '" > ');
	document.write('<param name="quality" value="high"> <embed quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.write('type="application/x-shockwave-flash" width="800" height="72" src="' + orgBanner + '"></embed></object>');
}

