
function emailvalidation(target, alertbox)
{
    var targetobj=document.getElementById(target);
    
    apos=targetobj.value.indexOf("@"); 
     
    dotpos=targetobj.value.lastIndexOf(".");
        
    lastpos=targetobj.value.length-1;
        
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
    {
        if (alertbox)
        {
            alert(alertbox);
			setfocus(target);
        }
        return false;
    }
    else
    {
        return true;
    }
}

function emptyvalidation(target, alertbox)
{
	//alert("Testing");
    var targetobj=document.getElementById(target);
//    alert(target);
//    alert(targetobj);
    if (targetobj.value==null || targetobj.value=="")
    {
            alert(alertbox);
			setfocus(target);
			return false;
    }
    else
    {
        return true;
    }
}
//to check textboxes
function customvalidation(target, alertbox1,numbers,alertbox2,flag)
{
    var targetobj=document.getElementById(target);
    var flg=flag;
//    alert(target);
//    alert(targetobj);

    if (targetobj.value==null || (targetobj.length > numbers && flg==0))
    {
        if (alertbox1!="")
        {
            alert(alertbox1);
        }
        return false;
    }
    else if(targetobj.value==null || (targetobj.value=="" && flg==1))
    {
        if (alertbox2!="")
        {
            alert(alertbox2);
        }
        return false;
    }
    else
    {
        return true;
    }
}
function CameraValidation(target1,target2,alertbox)
{
   var selected1 = document.getElementById(target1);
   var selected2=  document.getElementById(target2);

if (selected1.value ==0 && selected2.value =="") 
{
      if (alertbox!="")
        {
            alert(alertbox);
        }
       return false;
}

 else
 {
 return true;
 }

}
function emptyvalidationPASSWORD(target, lbl, alertbox)
{
    var targetlbl=document.getElementById(lbl);
    var targetobj=document.getElementById(target);
    
    if(targetobj.value==null || targetobj.value=="")
    {
        if(targetlbl.value==null || targetlbl.value=="")
        {        
            if (alertbox!="")
            {
                alert(alertbox);
            }
            return false;
        }
        else
        {
            return true;
        }
    }
    else
        return true;
}

//DropDownList Validation
function DropDownValidation()
{

if (document.getelementbyid("forum__ctl0_category").value == 0)
{
alert('Plese select a value from dropdown')
return false;
}
return true;
}

//DropDownList Validation for ""
function DropDownValidation(ddl)
{
var ddlobj=document.getElementById(ddl);
if (ddlobj.value == "")
{
alert('Plese select a value from dropdown')
return false;
}
return true;
}


 

function valuevalidation(entered, min, max, alertbox, datatype)
{
    with (entered)
    {
        checkvalue=parseFloat(value);
        if (datatype)
        {
            smalldatatype=datatype.toLowerCase();
            if (smalldatatype.charAt(0)=="i")
            {
                checkvalue=parseInt(value)
            };
        }
        if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
        {
            if (alertbox!="")
            {
                alert(alertbox);
            }
            return false;
        }
        else
        {
            return true;
        }
    }
}

function setfocus(a_field_id)
{
    document.getElementById(a_field_id).focus()
}



 function isInteger(digit)
{
    var i;
    
    for (i = 0; i < digit.length; i++)
    {
        var c = digit.charAt(i);

        if (!isDigit(c))
            return false;
    }

    return true;
}

 function isIntegerChkRange(target,alertbox)
{
//alert(target);
//var objtarget=document.getElementById(target);

var objtargetValue=target.value;
 var where_is=objtargetValue.indexOf('.');
 
//alert(where_is);
if(where_is==-1)
{
    var i;
    
    for (i = 0; i < objtargetValue.length; i++)
    {
        var c = objtargetValue.charAt(i);

        if (!isDigit(c))
        {
        alert(alertbox);
           return false;
         }
    }
//   alert(objtargetValue);
    
    if(objtargetValue>=0 && objtargetValue<=10)
    {
//    alert('aa');
        return true;
    }
    else
    {
        alert('Enter value from (0-10)');
         return false;
    }
    return true;
 }
    else
    {
    alert(alertbox);
     return false;
    }
}

function isDigit (c)
{
    return ((c >= "0") && (c <= "9"));
}

function validateIntForGrid(target, alertbox)
{
//  alert(target.id);
    var o = document.getElementById(target.id);
    var v = o.value;
//    alert(v);
    var where_is=v.indexOf('.');
        
    if(where_is > -1)
    {
        var first = v.split(".");
        
        if (!isInteger(first[0])) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
        {
            if (!isInteger(first[1])) 
            { 
                alert(alertbox);
                setfocus(target);
                return false;
            }
            else
            {
                if(first[1].length > 2)
                {
                    alert('Decimal part cann\'t be more than 2 digits!');
                    setfocus(target);
                    return false;
                }
                else
                    return true;
            }
        }
   }
   else
   {
        if (!isInteger(v)) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
            return true;
   }
}

function validateInt(target, alertbox)
{
//  alert(target.id);
    var o = document.getElementById(target);
    var v = o.value;
//    alert(v);
    var where_is=v.indexOf('.');
        
    if(where_is > -1)
    {
        var first = v.split(".");
        
        if (!isInteger(first[0])) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
        {
            if (!isInteger(first[1])) 
            { 
                alert(alertbox);
                setfocus(target);
                return false;
            }
            else
            {
                if(first[1].length > 2)
                {
                    alert('Decimal part cann\'t be more than 2 digits!');
                    setfocus(target);
                    return false;
                }
                else
                    return true;
            }
        }
   }
   else
   {
        if (!isInteger(v)) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
            return true;
   }
}
   
function comparevalidation(first, second, alertbox)
{
    var firstobj=document.getElementById(first);
    var secondobj=document.getElementById(second);
    
    if(firstobj.value==secondobj.value)
        return true;
    else
    {
        if (alertbox!="")
        {
            alert(alertbox);
        }
        return false
    }
}

function checkCheckBoxes(checkbox, alertbox)
 {
     var checkboxobj=document.getElementById(checkbox);
	if (checkboxobj.checked == false)	
	{
			alert (alertbox);
			
		return false;	
	}
		else	
	{	
		return true;
		
	}
	
}



function createuser_validation(username,firstname,lastname, email, confirmemail,pass, re_pass,checkbox,ddl)
{
   return (emptyvalidation(username, 'User Name cannot be empty!') && emptyvalidation(firstname, 'First Name cannot be empty!') &&  emptyvalidation(lastname, 'Last Name cannot be empty!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!') && comparevalidation(email, confirmemail, 'Email Mismatch!') && emptyvalidation(pass,'Password cannot be empty!') && comparevalidation(pass, re_pass, 'Password Mismatch!') && checkCheckBoxes(checkbox,'You must accept the site terms and conditions') && DropDownValidation(ddl));
}

function passwordchange_validation(oldpass,newpass,confirmpass)
{
   return (emptyvalidation(oldpass, 'Current Password cannot be empty!') && emptyvalidation(newpass, 'New Password cannot be empty!') &&  emptyvalidation(confirmpass, 'Confirm Password cannot be empty!') && comparevalidation(newpass, confirmpass, 'Password Mismatch!'));
}

function updateuser_validation(username,firstname,lastname, email, ddl)
{
   return (emptyvalidation(username, 'User Name cannot be empty!') && emptyvalidation(firstname, 'First Name cannot be empty!') &&  emptyvalidation(lastname, 'Last Name cannot be empty!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!') && valDropDownList(ddl, 'Please Select Country!') );
}

function createmessage_validation(subject,msg)
{
   return (emptyvalidation(subject, 'Subject cannot be empty!') && emptyvalidation(msg, 'You must enter a message.') );
}
//===========================================================================
//function createuser_validation(pass, re_pass,name,address, city, state, country, zip, phone, email)
//{
//   return (emptyvalidation(pass,'Password cannot be empty!') && comparevalidation(pass, re_pass, 'Password Mismatch!') && emptyvalidation(name, 'Name cannot be empty!') &&  emptyvalidation(address, 'Address cannot be empty!') && emptyvalidation(city, 'City cannot be empty!') && emptyvalidation(state, 'State cannot be empty!') && emptyvalidation(country, 'Country cannot be empty!') && emptyvalidation(zip, 'Zip cannot be empty!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(phone, 'Phone cannot be empty!') && validatePhone(phone, 'Invalid Phone no!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!'));
//}





//=====================================================================================================

//function createrestaurant_validation(REST_Name,REST_DESC,REST_Address,REST_City, State, Zip,Phone,REST_FAX, Email, REST_LOCATION,REST_HOUR,REST_FOOD_DELIVERY)
//{
//   return (emptyvalidation(REST_Name, 'Empty Restaurant Name!') && emptyvalidation(REST_DESC, 'Empty Restaurant Description!') && emptyvalidation(REST_Address, 'Empty Restaurant Address!') && valDropDownList(REST_City, 'Please Select City!') && emptyvalidation(State, 'Empty State value!') && emptyvalidation(Zip, 'Empty Zip Code!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(Phone, 'Empty Phone No!') && validatePhone(Phone,'Check Phone No!') && emptyvalidation(REST_FAX, 'Empty Fax!') && emailvalidation(Email, 'Invalid Email Id!') && emptyvalidation(Email, 'Empty Email Id!') && emptyvalidation(REST_LOCATION, 'Empty Restaurant Location!') && emptyvalidation(REST_HOUR, 'Empty Restaurant Hour Operation!') && emptyvalidation(REST_FOOD_DELIVERY, 'Empty Delivery!'))
//}

//function createmenu_validation(menu_Name,menu_desc,price, restaurant, category)
//{
//   return (emptyvalidation(menu_Name, 'Empty Menu Name!') && emptyvalidation(menu_desc, 'Empty Menu Description!') && emptyvalidation(price, 'Empty Menu Price!') && formatNum(price, 'Price Should be 2 digit decimal!') && valDropDownList(restaurant, 'Select Restaurant!')&& valDropDownList(category, 'Select Category!'))
//}
//================================================================================================
//function createUser_validation(U_Name,PAass,RePass, Address, City, State, Country,Zip,Phone,Email)
//{
//   return (emptyvalidation(U_Name, 'Empty User Name!') && emptyvalidation(PAass, 'Enter Password!') && emptyvalidation(RePass, 'Enter Re-Password!') && emptyvalidation(Address, 'Empty Address') && emptyvalidation(City, 'Empty City value!') && emptyvalidation(State, 'Empty State value!') && emptyvalidation(Country, 'Empty Country Value!') && emptyvalidation(Zip, 'Empty Zip Code!') && emptyvalidation(Phone, 'Empty Phone No!') && emailvalidation(Email, 'Invalid Email Id!') && emptyvalidation(Email, 'Empty Email Id!'))
//}


//validate Image Inputs
//function ValidateInputs(ImgTitle,ImgDescription,ImgShotSettings,ImgFontColor,ImgBackColor,Camera,Lens,CheckCritique,txtCritique)
//{
//    return(customvalidation(ImgTitle,'Image title may not be more than 50 characters',50,'Image Title cannot be blank',1) && customvalidation(ImgDescription,'Image description may not be more than 1000 characters',1000,'Image Description cannot be blank',1) && customvalidation(ImgCamera,'Camera name may not be more than 100 characters',100,'Camera name cannot be blank',0) && customvalidation(txtImgLens,'Lens name may not be more than 100 characters',100,'Lens name cannot be blank',0) && customvalidation(ImgShotSettings,'Image shot setting may not be more than 250 characters',250,'Image shot setting cannot be blank',0) && customvalidation(ImgBackColor,'',250,'Image backcolor cannot be blank',1) && customvalidation(ImgFontColor,'',250,'Image backcolor cannot be blank',1) && valDropDownList(Camera,'You must select a Camera') && valDropDownList(Lens,'You must select a Lens') && chkCritique(CheckCritique,txtCritique))
//}

function ValidateInputs(ImgTitle,ddlCategory,ImgDescription,ImgShotSettings,ImgFontColor,ImgBackColor,Camera,Lens,CheckCritique,txtCritique)
{
    return(customvalidation(ImgTitle,'Image title may not be more than 50 characters',50,'Image Title cannot be blank',1) && valDropDownList(ddlCategory,'Please select a category!') && customvalidation(ImgDescription,'Image description may not be more than 1000 characters',1000,'Image Description cannot be blank',1) && customvalidation(ImgShotSettings,'Image shot setting may not be more than 250 characters',250,'Image shot setting cannot be blank',0) && customvalidation(ImgBackColor,'',250,'Image backcolor cannot be blank',1) && customvalidation(ImgFontColor,'',250,'Image backcolor cannot be blank',1) && valDropDownList(Camera,'You must select a Camera') && valDropDownList(Lens,'You must select a Lens') && chkCritique(CheckCritique,txtCritique))
}

function chkCritique(CheckCritique,txtCritique)
{

var critiqueChk=document.getElementById(CheckCritique);

if(critiqueChk.checked==true)
{
    var txtValCritique=(document.getElementById(txtCritique)).value;
    if(txtValCritique=='')
    {
        alert('Please Enter Text for Critique Request');
     return false;
   
    }
    else
    {
    return true;
    }
}
else
{
return true;
}
}

function Upload_Validation(txtTitle,txtdescription,category)
{
  return(emptyvalidation(txtTitle, 'Image title cannot be blank!') && emptyvalidation(txtdescription, 'Image description cannot be blank!') && valDropDownList(category,'You must select a category'))
}
function alert1()
{
   //alert('abcd');
   alert(isInteger('1'));
}

//function BlogEntry_Validation(txtTitle,txtdescription)
//{
//  return(emptyvalidation(txtTitle, 'Blog title cannot be blank!') && emptyvalidation(txtdescription, 'Blog description cannot be blank!'))
//}
//function BlogUpdate_Validation(txtTitle,txtdescription)
//{
//  return(emptyvalidation(txtTitle, 'Blog title cannot be blank!') && emptyvalidation(txtdescription, 'Blog description cannot be blank!'))
//}

function BlogEntry_Validation(txtTitle)
{
  return(emptyvalidation(txtTitle, 'Blog title cannot be blank!'))
}



function validatePhone(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{10}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}

function validateMobile(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{10}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}

function valDropDownList(target, alertbox)
 {
var selected = document.getElementById(target);
//alert(selected);
//alert(selected.value);
if (selected.value ==-1) 
{
alert(alertbox);
return false;
}
 else
 { 
 return true;
 }
} 


function validateZip(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{4}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}

function IsMatchFloat(target,alertbox)
{
var mystring=document.getElementById(target);
//    mystring = str;
    if (mystring.match(/^\d+$|^\d+\.\d{2}$/ ) ) 
    {
     
        return true;
    }
    else
    {
       if (alertbox!="")
        {
            alert(alertbox);
        }
        return false;
    }
}

function formatNum(target,alertbox) 
{
var con = document.getElementById(target);
var s=con.value;
//alert(target);
//alert(s);
var OK = /^\d{1,9}(\.\d\d?)?$/.test(s);
if (OK) 
{
s = s.replace(/(\.\d)$/, "$10").replace(/^(\d+)$/, "$1.00")
return true;
} 
else 
{
//alert(s);
//      if (alertbox!="")
//        {
            alert(alertbox);
            return false;
//        }
        
}

}

function getObject(obj)
{
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) 
{

//alert(characters);
  var entranceObj=document.getElementById(entrance);
//  alert(entranceObj);
  var exitObj=document.getElementById(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}



//*****************************Functions written by Sourav**************************************

function validate_Month_Day_Year_Hour_Min_Sec(target,alertbox,type, min_val, max_val)
{
//  alert(target.id);
    var o = document.getElementById(target);
    var v = o.value;
	//alert(v.length);
	if(v.length>1)
	{
		//alert("Hello");
	var	l=v.length-1;
		if(v.substr(0,1)=='0')
		{
			v=v.substr(1,l);
		}
	}
   // alert(v);
	var num_v=parseInt(v);
	//alert(num_v);
	if(!isInteger(v))
	{
		alert(alertbox);
		setfocus(target);
		return false;
	}
	else if(num_v<min_val )
	{
		alert(type+" Must be Between "+min_val+"-"+max_val);
		//alert('ggggggggg');
		setfocus(target)
		return false;
	}
	else if(num_v>max_val)
	{
		alert(type+" Must be Between "+min_val+"-"+max_val);
		//alert('ggggggggg');
		setfocus(target)
		return false;
	}
	else
	{
		 return true;
	}
}


function real_int(target,alertbox)
{
	var o = document.getElementById(target);
    var v = o.value;
	//alert(v);
	if(!isInteger(v))
	{
	alert(alertbox);
	setfocus(target);
	return false;
	}
	else
	{
	return true;
	}
}

function other_id_req_check(target1,target2,alertbox)
{
	var o1 = document.getElementById(target1);
    var v1 = o1.value;
	var o2 = document.getElementById(target2);
    var v2 = o2.value;
	if(v1=='Other')
	{
		if(v2=="")
		{
			alert(alertbox);
			setfocus(target2);
			return false;
		}
		else
		{
		return true;
		}
	}
	else
	{
	return true;
	}
}



///****************************************** common functions **********************//
function setValueDiv(target,tvalue)
{

 	if(tvalue!=null)
 	{
		obj = document.getElementById(target);
		if(obj!=null)
		{
		    obj.innerHTML = tvalue; 	
		}
	}
}

function setValueImage(target,tvalue,img_height,img_width)
{
	//alert("Height="+img_height+"   width="+img_width);
 	if(tvalue!=null)
 	{
		obj = document.getElementById(target);
		obj.src = tvalue; 	
		if(img_height!='')
		{
		obj.height=img_height;
		}
		if(img_width!='')
		{
		obj.width=img_width;
		}
		
		
		
	}
}

function hideElement(target)
{
		obj = document.getElementById(target);
		obj.style.visibility='hidden';

}

function setValue(target,tvalue)
{
 	//alert('setValue')
 	//alert(target);
 	//alert(tvalue);
 	if(tvalue!=null)
 	{
		obj = document.getElementById(target);
		if(obj!=null)
		{
		obj.value = tvalue; 	
		}
	}
}


function setValueRD(target)
{
 	//alert('setValue')
 	//alert(target);
 	//alert(tvalue);
 	if(target!=null)
 	{
		obj = document.getElementById(target);
		if(obj!=null)
		{
		obj.checked = true;	
		}
	}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}





/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1000;
var maxYear=3000;

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 strMonth=dtStr.substring(0,pos1)
	var strDay=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 : mm/dd/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 datevalidation(id,alertbox){
	var dt=document.getElementById(id);
	if (isDate(dt.value)==false){
		dt.focus()
		alert(alertbox);
		return false
	}
    return true
 }
 
 function replacecarriagereturn(textarea,replaceWith)   
{ 

var val=document.getElementById(textarea).value;
// alert(replaceWith);  
 val = escape(val);   
   //encode all characters in text area   
   //to find carriage return character   
 for(i=0; i < val.length; i++)   
 {    
  //loop through string, replacing carriage return    
  //encoding with HTML break tag   
  if(val.indexOf("%0D%0A") > -1)   
  {    
   //Windows encodes returns as \r\n hex   
   val=val.replace("%0D%0A",replaceWith);   
  }   
  else if(val.indexOf("%0A") > -1)   
  {    
   //Unix encodes returns as \n hex   
   val=val.replace("%0A",replaceWith);   
  }   
  else if(val.indexOf("%0D") > -1)   
  {    
   //Macintosh encodes returns as \r hex   
   val=val.replace("%0D",replaceWith);   
  }   
 }   
 val=unescape(val);   
//decode all characters in text area back
//alert(val);
  document.getElementById(textarea).value=val; 
} 
////**************************************** End of Common Functions ********************//