//function to check no of character

function ValidateSpace(poControl, psName)
{
  
        string=poControl.value
	if(string.indexOf(" ")>0)
		{
			alert("Space is not allow in " + psName );
			poControl.focus();
			return false;
		}


	return true;

}

function validatelen(txtobj)
{

if(txtobj.value.length<500)
{
return true;
}
else
{
txtobj.value=txtobj.value.substring(0,500);
return false;
}
}


function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return tempX  + ','  + tempY
}


//function to compare date

function DateCompare(startobj,endobj) 
{
if(startobj.value != "" && endobj.value != "")
{
var myMonth = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var firstIndex=startobj.value;
var secondIndex=endobj.value;
 
if(firstIndex.indexOf("/") > 0)
{
	var f1=firstIndex.indexOf("/")
	var f2=firstIndex.lastIndexOf("/")
	var f3=firstIndex.substring(f1+1,f2)


	for(i=0;i< myMonth.length;i++)
	{
		if(f3==myMonth[i])
		{
			var first=firstIndex.replace(f3,i+1)
		}
	}
	var f11=first.indexOf("/")
	var f12=first.lastIndexOf("/")

	var fmonth=first.substring(f11+1,f12)
	var fday=first.substring(0,f11)
	var fyear=first.substring(f12+1,first.length)
}
else
{
	var f1=firstIndex.indexOf(" ")
	var f2=firstIndex.lastIndexOf(" ")
	var f3=firstIndex.substring(0,f1)

	for(i=0;i<myMonth.length;i++)
	{
		if(f3==myMonth[i])
		{
			var first=firstIndex.replace(f3,i+1)
		}
	}

	var f11=first.indexOf(" ")
	var f12=first.lastIndexOf(" ")

	var fmonth=first.substring(0,f11)
	var fday=first.substring(f11+1,f12)
	var fyear=first.substring(f12+1,first.length)
}

if(secondIndex.indexOf("/") > 0)
{
         
	var s1=secondIndex.indexOf("/")
	var s2=secondIndex.lastIndexOf("/")
	var s3=secondIndex.substring(s1+1,s2)

	for(i=0;i<myMonth.length;i++)
	{
		if(s3==myMonth[i])
		{
			var second=secondIndex.replace(s3,i+1)
		}
	}

	var s11=second.indexOf("/")
	var s12=second.lastIndexOf("/")

	var smonth=second.substring(s11+1,s12)
	var sday=second.substring(0,s11)
	var syear=second.substring(s12+1,second.length)

}
else
{
	var s1=secondIndex.indexOf(" ")
	var s2=secondIndex.lastIndexOf(" ")
	var s3=secondIndex.substring(0,s1)

	for(i=0;i<myMonth.length;i++)
	{
		if(s3==myMonth[i])
		{
			var second=secondIndex.replace(s3,i+1)
		}
	}


	

	var s11=second.indexOf(" ")
	var s12=second.lastIndexOf(" ")

	var smonth=second.substring(0,s11)
	var sday=second.substring(s11+1,s12)
	var syear=second.substring(s12+1,second.length)
}

if(fyear<=syear)
{
   if(fyear==syear) 
   { 
	if(eval(fmonth)<=eval(smonth))
 	{
   		if(eval(fmonth)==eval(smonth)) 
   		{
     			if(eval(fday)<=eval(sday))    
     			{
       				return true;
     			}
     			else
     			{
          			alert ("Select " + startobj.name + " greater then " + endobj.name + ".");
          			return false;
     			}
   		}
   		return true; 
 
 	}
   }
   else
   {
       return true; 
   }
} 
  alert ("Select " + startobj.name + " greater then " + endobj.name + ".");
  return false;
 }
else
{
return true;
}
}


//function gets selected index value for a combo

function GetSelectedComboItem(cmb)
{
return cmb.options[cmb.selectedIndex].value
}

function AddToText(obj,txtvalue)
{
obj.value=txtvalue;
}

function GetSelectedComboText(cmb)
{
return cmb.options[cmb.selectedIndex].text
}

//Function to get List of all selected items from ListBox or Check or Radio Box
function listValuesCheckBox(checkBoxRef)
{
var len = 0
var list = ''
if (!checkBoxRef.length) {
  if (checkBoxRef.checked) { 
    list = checkBoxRef.value ;
    return list ;
  }
}

len=checkBoxRef.length ;
for (var i=0; i<len; i++){
  if (checkBoxRef[i].checked) {
    list+= checkBoxRef[i].value + ',';
  }
  }
return list
}



var func1; 

//This function could be used when call ShowDivInURL and ShowDiv when you do not want call back function
// Example showcontentindiv('Title','PageName','Parameters','Btn1','Btn2',dummy)
function dummy(btn) 
{ 
return;
}



function dydivbuttonclicked(no)
{
if (func1) func1.apply(null,[no]) ;
var formid = document.getElementById("dydiv_alerform")
if (formid) formid.style.display = 'none';
func1 = '';
}


//Get Page content in a ID as passed by user. Using AJAX. 

function showcontentindiv(page,parameters,containername)
{
var containerid = document.getElementById(containername)
containerid.innerHTML = '<img valign="middle" align="center" border="0" src="/Images/loadingAnimation.gif">'
containerid.innerHTML = Getcontent(page ,parameters) ;
}


function closeopenindiv() 
{ 
var mydivid = document.getElementById(dy_divnametoopendiv) 
mydivid.innerHTML = ''
mydivid.style.display='none' ;
}

var dy_divnametoopendiv ;
function openindiv(page,parameters,divname,height,width)
{
dy_divnametoopendiv = divname ;
var mydivid = document.getElementById(divname) ;
mydivid.innerHTML = Getcontent(page ,parameters) ;
mydivid.width=width ;
mydivid.height=height ;
mydivid.style.left = acenterleft(width) ;
mydivid.style.top = acentertop(height) ;
mydivid.position= 'absolute';
mydivid.style.display='block';
}





//This functions gets HTML using Ajax and displays in a DIV window. Calls Call Back func on click of any button
function showdivurl(title,page,parameters,button1text,button2text,userfunc,timeout)
{
var formid = document.getElementById("dydiv_alerform")
var btn1 = document.getElementById("dydiv_button1")
var btn2 = document.getElementById("dydiv_button2")
var titleid = document.getElementById("dydiv_title")
var msgid = document.getElementById("dydiv_msg")
var x = (window.screen.width - 350) / 2;
var y = (window.screen.height - 400) / 2 ;

if (button1text != '') 
 { btn1.value = button1text ;
   btn1.style.display='block';
 } else btn1.style.display='none';

if (button2text != '') 
 { btn2.value = button2text ;
   btn2.style.display='block';
 } else btn2.style.display='none';

titleid.innerHTML = title ;
formid.style.left = acenterleft(350) ;
formid.style.top = acentertop(200) ;
func1 = userfunc ;
msgid.innerHTML = '<img valign="middle" align="center" border="0" src="/Images/loadingAnimation.gif">'
formid.style.display = 'block';
msgid.innerHTML = Getcontent(page ,parameters) ;
if ( (button2text == '' || button1text == '') && timeout ==null ) setTimeout("dydivbuttonclicked(0)",5000);
}


function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    //tempX = event.clientX + document.body.scrollLeft
   // tempY = event.clientY + document.body.scrollTop
  tempX = event.clientX 
    tempY = event.clientY 
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return tempX  + ','  + tempY
}


function acentertop(height)
{

var IE = document.all?true:false
if(IE) 
{ 
    tempY = event.clientY + document.body.scrollTop
} 
else 
{ 
    e = Event.MOUSEMOVE; 
    tempY = document.body.scrollTop;
}  

if (tempY < 0){tempY = 0} 
  
height=eval(height);
if ((tempY + height + 10) > ((document.body.scrollTop) + (document.body.offsetHeight)))
  return tempY - height - 10 ;
else
  return tempY + 10  ;


}


function acenterleftabc(width)
{

i = (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth ;
return (i/2) - (width/2) + (document.body.scrollLeft) ;
if (xMousePos - (width/2) > 0 )
   return xMousePos - (width/2) ;
else
   return (i/2) - (width/2) + (document.body.scrollLeft/2) ;



}


function acentertopold(height)
{
/*
i = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight ;
//return (i/2) - (height/2)  + (document.body.scrollTop)
if (yMousePos - (height/2) > 0 )
  return yMousePos - (height/2)
else
  return (i/2) - (height/2)  + (document.body.scrollTop/2) ;

alert("document.body.scrollTop= " + document.body.scrollTop + " - " + document.body.offsetHeight + " - " + " - " + height) 
*/

return (document.body.scrollTop) + (document.body.offsetHeight/2) - (height/2) 
}


function acenterleft(width)
{

i = (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth ;
return (i/2) - (width/2) + (document.body.scrollLeft) ;
if (xMousePos - (width/2) > 0 )
   return xMousePos - (width/2) ;
else
   return (i/2) - (width/2) + (document.body.scrollLeft/2) ;



}

//This functions shows Static Message. in a DIV window. On click of Button calls a call back function as defined by user
function showdiv(title,message,button1text,button2text,userfunc,timeout)
{
var formid = document.getElementById("dydiv_alerform")
var btn1 = document.getElementById("dydiv_button1")
var btn2 = document.getElementById("dydiv_button2")
var titleid = document.getElementById("dydiv_title")
var msgid = document.getElementById("dydiv_msg")

if (button1text != '') 
 { btn1.value = button1text ;
   btn1.style.display='block';
 } else btn1.style.display='none';

if (button2text != '') 
 { btn2.value = button2text ;
   btn2.style.display='block';
 } else btn2.style.display='none';
msgid.innerHTML = message ;
titleid.innerHTML = title ;


formid.style.left = acenterleft(350) ;
formid.style.top = acentertop(200) ;

func1 = userfunc ;
formid.style.display = 'block';
if (button2text == '' || button1text == '' && timeout ==null) setTimeout("dydivbuttonclicked(0)",5000);
}





function isenterkeypressed(field, evt) {
  var keyCode = evt.which ? evt.which : evt.keyCode;
  if (keyCode == 13) 
  {

      return true ;
  }    	
  else return false;
}


// Validates maxlength


 
function ValidateNo(e)
{

  var keyval =(window.event) ? event.keyCode : e.keyCode;


   if((keyval >47 && keyval<58) || keyval == 44 || keyval == 43 || keyval == 13 ) 
      {
         return true;
      }
   else
      {
        //event.keyCode = 0
        if(window.event) 
	 event.keyCode = 0 
	else
	 e.keyCode ="";
        return false;
      }


}

function Validatefloat()
{


   if((event.keyCode>47 && event.keyCode<58) || event.keyCode == 44 || event.keyCode == 43 || event.keyCode == 13 || event.keyCode == 46 ) 
      {
         return true;
      }
   else
      {
       
         event.keyCode = 0;
         return false;
      }
}

function ValidateLength(poControl, psLength, psName)
{
	lsLength = poControl.value.length
	if (lsLength > psLength)
		{
			alert("Please enter a value less than or equal to " + psLength + " for " + psName + " field.");
			poControl.focus();
			return false;
		}
	return true;
}
// For Validation of blank field and field with only spaces

function ValidateNull(poControl, psName)
{
	var str=" ";
	var count=0;
	var string;
	var maxLength;

	string=poControl.value
	if(string=="")
		{
			alert(" " + psName + " cannot be blank.");
			poControl.focus();
			return false;
		}

	maxLength=string.length;
	while(count < maxLength)
	{
		if(string==str)
		{
			alert("Please enter some value. " + psName + " cannot have all blanks.")
			poControl.value="";
			poControl.focus();
			return false;
		}
		else
		{
			str+=" ";
			count++;
		}
	}
	return true;
}


//for validate null and return true or false ,and do not alert for message 

function ValidateNullfield(poControl, psName)
{
	var str=" ";
	var count=0;
	var string;
	var maxLength;
      	string=poControl.value
	if(string=="")
		{
		    return false;
		}

	maxLength=string.length;
	while(count < maxLength)
	{
		if(string==str)
		{
			return false;
		}
		else
		{
			str+=" ";
			count++;
		}
	}
	return true;
}

function AllNumber(poControl)
{
	if (!isFinite(poControl.value))
	{
		return false;
	}
	return true;
}


// For Validation of Number

function IsNumber(poControl, psName)
{
	if (!isFinite(poControl.value))
		{
			window.alert("Please enter Number for " + psName + " field.");
			poControl.value = "";
			poControl.focus();
			return false;
		}
	return true;
}


//For Validation of Email Fields
function IsEmail(poControl, psName)
{
	var count;
	var charcount;

	charcount=0;
	email=poControl.value.toLowerCase();

	for(count=0; count<email.length; count++)
	{
		if(email.charAt(count)=='@')
		{
			if(count==0)
			{
				alert("First character cannot be '@' for " + psName);
				poControl.focus();
				return false;
			}
			else
			{
				//Check atleast one character is present after the @
				charcount+=1;
				if(charcount>1)
				{
					//more than one @ present
					alert("There should be only one '@' for " + psName);
					poControl.focus();
					return false;
				}
				else
				{
					if(email.charAt(count+1)=="")
					{
						alert("There should be atleast one character after '@' for " + psName);
						poControl.focus();
						return false;
					}
				}
			}
		}
	}
	if (charcount < 1 )
	{
		alert("There should be atleast one '@' character for " + psName);
		poControl.focus();
		return false;		
	}
	return true;
}

//For Validation of Alphabetic Fields
function IsAlphabet(poControl, psName)
{	
	arg=poControl.value.toLowerCase();
	for(i=0; i<arg.length; i++)
		if(arg.substring(i,i+1)>"z" || arg.substring(i,i+1)<"a")
			if(arg.substring(i,i+1)!=" ")
			{
				alert("Invalid value for field " + psName);
				poControl.focus();
				return false;
			}
	return true;
}

//For validation of webmaster change password
function validatepassword()
{
//	alert ("submit!");
//check if old password is blank
if (frmchangepassword.txtoldpassword.value == "")
{
alert("You must enter your old password!");
frmchangepassword.txtoldpassword.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = frmchangepassword.txtoldpassword.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}

if (!allValid)
{
alert("Please enter only letter and numeric characters in the password field.");
frmchangepassword.txtoldpassword.focus();
return (false);
}
// check to see if the field is blank
if (frmchangepassword.txtnewpassword.value == "")
{
alert("You must enter a password!");
frmchangepassword.txtnewpassword.focus();
return (false);
}

// require at least 3 characters be entered
if (frmchangepassword.txtnewpassword.value.length < 8)
{
alert("Please enter at least 8 characters in the password field.");
frmchangepassword.txtnewpassword.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
checkStr = frmchangepassword.txtnewpassword.value;
allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only letter and numeric characters in the password field.");
frmchangepassword.txtnewpassword.focus();
return (false);
}

if (frmchangepassword.txtnewpassword.value!=frmchangepassword.txtnewpassword1.value)
{
alert("Please enter identical values when confirming your password!");
frmchangepassword.txtnewpassword1.focus();
return (false);
}

frmchangepassword.pwdchkval.value="valok";
return (true);
}
//For showing disclaimer
function ShowDisclaimer()
{
	window.open("disclaimer.htm");
}


function validalphanumeric(poControl, psName)
{
	// allow ONLY alphanumeric keys, no symbols or punctuation
	// this can be altered for any "checkOK" string you desire
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var checkStr = poControl.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{	if (ch == checkOK.charAt(j))
				break;
			if (ch == " ")
				break;
		}
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
	
	}
	if (!allValid)
	{
		alert("Please enter only letter and numeric characters in the " + psName);
		poControl.focus();
		return (false);
	}
	return true;
}

function validphone(poControl, psName)
{
	// allow ONLY alphanumeric keys, no symbols or punctuation
	// this can be altered for any "checkOK" string you desire
	var checkOK = "0123456789,";
	var checkStr = poControl.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{	if (ch == checkOK.charAt(j))
				break;
			if (ch == " ")
				break;
		}
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
	
	}
	if (!allValid)
	{
		alert("Please enter only number in " + psName);
		poControl.focus();
		return (false);
	}
	return true;

}

function IsAlphabetonly(poControl, psName)
{	var i;
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	var checkStr = poControl.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
	
	}
	if (!allValid)
	{
		alert("Please enter only letters in field " + psName);
		poControl.focus();
		return (false);
	}
	return true;
}

function validparam(poControl,psName)
{	var i;
	var arg=poControl.value.toLowerCase();
	for(i=0; i<arg.length; i++)
		if(arg.charAt(i)=="'" || arg.charAt(i)=="\"")
			{
				alert("Remove single code OR double code from " + psName);
				poControl.focus();
				return false;
			}
			
	return true;
}

function IsValidDate(poDateControl, psName) 
{ 
var monthalphaarray=new Array ("###","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); 
var montharray=new Array ("01","02","03","04","05","06","07","08","09","10","11","12"); 
var dayarray=new Array ("31","28","31","30","31","30","31","31","30","31","30","31"); 
var validationflag=1; 
var leapyrflag=0; 
var DateString=new String(poDateControl.value); 
var len=DateString.length; 

if(len == 0) 
	return true;


if(len > 10 ) 
{ 
alert("Invalid Date value for " + psName); 
poDateControl.focus(); 
return false; 
} 

var char1=DateString.charAt(2); 
var char2=DateString.charAt(5); 
//var dayvalue=DateString.substring(0,2);  for dd-mm-yyyy
//var monthvalue=DateString.substring(3,5); for dd-mm-yyyy
var monthvalue=DateString.substring(0,2); 
var dayvalue=DateString.substring(3,5); 

var yearvalue=DateString.substring(6,10); 

if (((parseInt(monthvalue,10) > 0) && (parseInt(monthvalue,10) < 13))) 
validationflag=1; 
else 
validationflag=0; 

if (((parseInt(dayvalue,10) < 1) || (parseInt(dayvalue,10) > 31))) 
validationflag=0; 

if (((parseInt(yearvalue,10) < 1) || (parseInt(yearvalue,10) >2100))) 
validationflag=0 ; 

if ((monthvalue.length !=2)||(dayvalue.length !=2)||(yearvalue.length !=4)) 
validationflag=0; 

if ( (parseInt(yearvalue,10)%4==0 && parseInt(yearvalue,10)%100 !=0) || (parseInt(yearvalue,10)%400==0) ) 
{ 
leapyrflag=1; 
if(monthvalue=="02") 
if(parseInt(dayvalue,10) > 29) 
validationflag=0; 
} 
else 
{ 
if(monthvalue=="02") 
if(parseInt(dayvalue,10) > 28) 
validationflag=0; 
} 

if (validationflag==0) 
{ 
alert("Invalid Date value for " + psName + "\n\n" + "Valid Date Format: MM/DD/YYYY"); 
poDateControl.focus(); 
return false; 
} 
else 
{ 
for(var j=0;j<12;j=j+1) 
{ 
if(monthvalue==montharray[j]) 
if(dayvalue>dayarray[j]) 
{ 
if(leapyrflag==1) 
{ 
if(monthvalue!="02") 
{ 
alert("Date Entered, " + dayvalue + " Exceeds Maximum No of Days for the Entered Month, " + monthalphaarray[parseInt(monthvalue,10)] + " for " + psName); 
return false; 
} 
} 
else 
{ 
alert("Date Entered, " + dayvalue + " Exceeds Maximum No of Days for the Entered Month, " + monthalphaarray[parseInt(monthvalue,10)] + " for " + psName); 
return false; 
} 
} 
} 
} 
return true; 
} 


function AddValueTocombo(comboobj , idvalue , textvalue )
{
    comboobj.length = comboobj.length +1 ;	           	           
    comboobj.options[comboobj.length-1].text = textvalue  ;
    comboobj.options[comboobj.length-1].value = idvalue  ;
  
}

function AddToText(obj,txtvalue)
{
obj.value=txtvalue;
}



function replacestring(arg,rstr,rwstr)
{
       if(arg.indexOf(rstr) >= 0)
        {
          arg = arg.replace(rstr,rwstr);
          arg = replacestring(arg,rstr,rwstr);
        }
        return arg;
}


function checkMe(myform,msgobj)
{
//CHECK ABUSE
        var enterchar =0 ;
	var abuse = new Array();
	abuse = Array("fuck-f*ck", "chod-ch*d", "bitch-b*tch", "bastard-b*st*rd", "suck-s*ck", "handjob-h*ndj*b", "blowjob-bl*wj*b", "chhod-chh*d");
 	for(i=0;i<abuse.length;i++)
	{
 	var a = msgobj.value;
 	var newa, abuseo, abuser;
 	newa = abuse[i].split("-");
 	abuseo = newa[0];
 	abuser = newa[1];
  	if(a.search(abuseo)!=-1)
  		msgobj.value = a.replace(abuseo, abuser);
 	}

	var fT, count, msga, ulta;
	var cnt=0;
	if(fT=="93")
		msga=150;
 	else
	 	msga = 2500;

	
        for (var j = 0; j < msgobj.value.length ; j++) {
        if(msgobj.value.charCodeAt(j)== '10' && navigator.appName != "Microsoft Internet Explorer")
        {
            enterchar = enterchar +1;
          }
        }
 	count = msgobj.value.length + enterchar;
	cnt=parseInt(count/160)+1;
	if((count%160)==0)
	{
		cnt--;
	}
	myform.echo2.value = count;
	myform.echo1.value = cnt;
        
        if(document.getElementById('Adlength'))
        {
            adlen = document.getElementById('Adlength').value
            if(adlen>0)
            {
                msga=160 - adlen;
            }

            if(count>msga)
            {
              alert("Maximum Messages Size Reached");
              msgobj.value = msgobj.value.substring(0, msga);
              myform.echo2.value = msga;
            }  
        }
          
        
         
}




function Getcontent(URLPath,URLCont)
{

 var xmlHttp,xmlopt ;
 xmlopt ='';
  try
    {
       xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
       try
      {
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        try
        {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
               alert("Your browser does not support AJAX!");
                 xmlopt =''; 
        }
      }
    }


    xmlHttp.onreadystatechange=function()
      {
        if(xmlHttp.readyState==4)
        {
          if(xmlHttp.responseText=='')
          {
          	//alert("Please try again after some time")
                xmlopt ='';  
          }
             xmlopt = xmlHttp.responseText	  
        }
      }
    
    xmlHttp.abort();  
	
    xmlHttp.open("POST",URLPath,false);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(encodeURI(URLCont));

    if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
          if(xmlHttp.responseText=='')
          {
          	//alert("Please try again after some time")
                xmlopt ='';  
          }
             xmlopt = xmlHttp.responseText	
           
        }   
  
    return xmlopt
 }


function Getcontent1(URLPath,URLCont)
{

 var xmlHttp,xmlopt ;
 xmlopt ='';
  try
    {
       xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
       try
      {
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        try
        {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
               alert("Your browser does not support AJAX!");
                 xmlopt =''; 
        }
      }
    }

    xmlHttp.onreadystatechange = function()
      {
     
        if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
          if(xmlHttp.responseText=='')
          {
          	//alert("Please try again after some time")
                xmlopt ='';  
          }
             xmlopt = xmlHttp.responseText	
           
        }
      }

    xmlHttp.abort();

    xmlHttp.open("POST",URLPath,false);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(encodeURI(URLCont));

    if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
     {
         if(xmlHttp.responseText=='')
          {
          	//alert("Please try again after some time")
                xmlopt ='';  
          }
             xmlopt = xmlHttp.responseText	
           
        }

     return xmlopt

 }



function getcheckedradiovalue(radioObj) {

	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	
        if(!isFinite(radioLength) )
	{
           	if(radioObj.checked)
                  return radioObj.value;
		else return "";
	}
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}

	return "";
}

function getcheckedradioID(radioObj) {

	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	
        if(!isFinite(radioLength) )
	{
           	if(radioObj.checked)
                  return radioObj.id;
		else return "";
	}
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].id;
		}
	}

	return "";
}

function getselectedcombovalue(comboObj)
{
  var selcomboval
  selcomboval ='';

        if(!comboObj)
		return "";
	var comboLength = comboObj.length;
	  

        if(!isFinite(comboLength) )
	{
           	if(comboObj.selected)
                  return comboObj.value;
		else return "";
	}

	for(var i = 0; i < comboLength; i++) 
	{
		if(comboObj[i].selected) 
		{
			selcomboval = selcomboval  + comboObj[i].value + ',';
		}
           
	}
        selcomboval = selcomboval.substring(0,selcomboval.length-1)
	return selcomboval;

}


function selectecombovalue(comboObj,selvalue)
{
  var selcomboval
  selcomboval ='';

        if(!comboObj)
		return ;
	var comboLength = comboObj.length;
	  

	for(var i = 0; i < comboLength; i++) 
	{
		if(comboObj[i].value == selvalue ) 
		{
			comboObj[i].selected =true;
		}
           
	}
   

}

function getselectedcheckboxvalue(chObjname)
{
 
	var e,str;
str='';
	for (i = 0;i<window.document.getElementsByTagName("input").length;i++)
	{
		e = window.document.getElementsByTagName("input").item(i);
		if( e.type == "checkbox" && e.name == chObjname && e.checked == true)
		{
                  str= e.value + ',' + str ;
                  	
                }	
	}
        str = str.substring(0,str.length-1)

return  str;

}

function getselectedcheckboxid(chObjname)
{
 
	var e,str;
str='';
	for (i = 0;i<window.document.getElementsByTagName("input").length;i++)
	{
		e = window.document.getElementsByTagName("input").item(i);
		if( e.type == "checkbox" && e.name == chObjname && e.checked == true)
		{
                  str= e.id + ',' + str ;
                  	
                }	
	}
 str = str.substring(0,str.length-1)
return  str;

}

function Uncheckcheckbox(chObjname,setval,setstatus)
{
 
	var e;

	for (i = 0;i<window.document.getElementsByTagName("input").length;i++)
	{
		e = window.document.getElementsByTagName("input").item(i);
		if( e.type == "checkbox" && e.name == chObjname && e.value == setval)
		{
                    if(setstatus == 0) 
                      e.checked = false ;
                    else
                      e.checked = true ;	
                }	
	}



}


function getselectedobject(chObjname)
{
 
	var e,str;
str='';
	for (i = 0;i<window.document.getElementsByTagName("input").length;i++)
	{
		e = window.document.getElementsByTagName("input").item(i);
		if( e.type == "checkbox" && e.name == chObjname)
		{
			window.document.getElementsByTagName("input").length
			return e;
                  	
                }	
	}

}


//below functions gets us current mouse positions
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

if (document.layers) 
{ // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
	} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
    } else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}


function ConvertBR(input,repstr) {
// Converts carriage returns 
// to <BR> for display in HTML
//alert(input.length)
var output = "";
for (var i = 0; i < input.length; i++) {

if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10)) {
i++;
output += repstr;
} else {
output += input.charAt(i);
   }
}
return output;
}


function loadimage(imgobj,imgobj2,oldheight,oldwidth)
{
 
   var newheight,newwidth;  

   imgwidth = window.frames['imageloader'].document.getElementById(imgobj2).width;
   imgheight = window.frames['imageloader'].document.getElementById(imgobj2).height;

if(imgwidth < oldwidth && imgheight < oldheight)
{
   document.getElementById(imgobj).height=imgheight;
   document.getElementById(imgobj).width= imgwidth;
}
else
{
  if(imgheight > oldheight || imgwidth > oldwidth)
  {
    if ( eval(imgheight) / eval(oldheight) > eval(imgwidth) / eval(oldwidth) )
        HigherNum = eval(imgheight) / eval(oldwidth) 
    else
        HigherNum =  eval(imgwidth) / eval(oldwidth)
    
    newwidth = eval(imgwidth) / eval(HigherNum);
    newheight = eval(imgheight) / eval(HigherNum);

  }
  else
  {
        if ( oldheight / imgheight > oldwidth / imgwidth )
              HigherNum1 = eval(oldwidth) / eval(imgheight) 
        else
              HigherNum1 = eval(oldheight) / eval(imgheight)
        
        newwidth = eval(imgwidth) * eval(HigherNum1);
        newheight = eval(imgheight) * eval(HigherNum1);
  }
  
   document.getElementById(imgobj).height=newheight;
   document.getElementById(imgobj).width= newwidth;
}

   document.getElementById(imgobj).src =window.frames['imageloader'].document.getElementById(imgobj2).src;
}

function setspanvalue(objid,val)
{
document.getElementById(objid).innerHTML = val;
}

function clearspanvalue(objid)
{
document.getElementById(objid).innerHTML ='';

}

function GetOptionValue(comboobj,cmbvalue,comboobj2,framename)
{

var cmbname = comboobj.options[comboobj.selectedIndex].value;
window.frames[framename].location = 'nomenumainnew.asp?page=getoptionvalue&othercomboobj=' + comboobj2 +'&cmbname=' + cmbname + '&cmbvalue=' + cmbvalue 


}