 //------- this function for valid xml 4/march---//
 function ValidXML(e) 
 {
       var evt = e || window.event;            
       var txtBox=evt.target || evt.srcElement;                
      //var exp =  /[^\<>&"“”]/g; 
      var exp ="'"; 
        exp +=  ',<,>,&,",“,”';
       exp=exp.split(',')
       for(var i=0;i<exp.length;i++)
       {
       txtBox.value = txtBox.value.replace(exp[i],'');
       }              
 }
 
  function AcceptDate(e)
 {
       var evt = e || window.event;            
       var txtBox=evt.target || evt.srcElement;                
      var exp = /[^\d/]/g;   
       txtBox.value = txtBox.value.replace(exp,'');
                    
 }

//////////////////////////////////////////////////////////////////////////
// Trim function 
///////////////////////////////////////////////////////////////////////////
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
} // End function trim();

////////////////////////////////////////////////////////////////////////////////
// Functio to verify wheter user select scrutiny section "No" then he will back
// his default page.
///////////////////////////////////////////////////////////////////////////////
function _isrodSelected(rdoval)	
	{ 
		if (document.all("rdo"+rdoval+"").checked == true)
			{   
			var i = confirm("If not do not accept the form");
			if (i)
				document.location.href = "../Login/DefaultUserPage.aspx";
			else
			  {
				sClick = "F";
				return true;
			  }	
			}
	} // end function function _isrodSelected(rdoval)


//////////////////////////////////////////////////////////////////////////////////////
//****Check Strickly Number
/////////////////////////////////////////////////////////////////////////////////////
function isNumaric( s ) {
   var digit;
	var b = parseInt(s).length;
   for (i = 0; i < b; ++ i) {
      digit = s.charAt(i);
      switch( digit ) {
      case '0': case '1': case '2': case '3': case '4': case '5':
      case '6': case '7': case '8': case '9':
         break;
      default:
         return false;
      }
   }

   return true;
}

/////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//****String Left formating
/////////////////////////////////////////////////////////////////////////////////////

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

/////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//****String Right formating
/////////////////////////////////////////////////////////////////////////////////////

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
/////////////////////////////////////////////////////////////////////////////////////

/******************************************************************************/
//Date check function
function isDateValid(dateStr)
{
  var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
  var matchArray = dateStr.match(datePat); // is format OK?

  if (matchArray == null) {
    return false;
  }

  // parse date into variables
  month = matchArray[3];
  day = matchArray[1];
  year = matchArray[5];

  if (year < 1900 || year >= 2080) { 
    return false;
  }


  if (month < 1 || month > 12) { 
    return false;
  }

  if (day < 1 || day > 31) {
    return false;
  }

  if ((month==4 || month==6 || month==9 || month==11) && day==31) {
    return false;
  }

  if (month == 2) { // check for february 29th
    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
    if (day > 29 || (day==29 && !isleap)) {
      return false;
    }
  }
  return true;  // date is valid
}

	///Function to check difference between two date
    function dateDiff(d1, d2) 
    {           
		var days = (Date.parse(d1.toString()) - Date.parse(d2.toString())) / (1000 * 60 *60 * 24);
			return days;
    }

////////////////////////////////////////////////
//// function change title
///////////////////////////////////////////

//***************** Format Value ******************

function formatCurrency(num) {
			//num = num.toString().replace(/\$|\,/g,'');
			if(isNaN(num))
			num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();
			if(cents<10)
			cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+
			num.substring(num.length-(4*i+3));
			return (((sign)?'':'-') +  num + '.' + cents);			
		}
		
// ************ End Formating Value **************************		


///////////// BUSY ICON  //////////////////
var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialogEventHandler = '';
var ctr;
var mainDiv = document.getElementById("divprgBar");
var ctrMax;

    function ModalDialogMaintainFocus()
    {
        var popup = ctl00_rightContainer_CB3;
        try
        {
            if (popup.visibility == "hidden")
            {
                clearInterval(ModalDialogInterval);
                eval(ModalDialogEventHandler);
                return;
            }
            popup.Show('LightBlue'); 
        }
        catch (everything) { }
    }

    function ModalDialogRemoveWatch()
    {
        ModalDialogEventHandler = '';
    }

    function ShowPopup()
    {
      var hdnId = document.getElementById("loading");
      hdnId.value = "waiting";
      Process();
      return true;
    } 

    function Process()
	{
	    ModalDialogRemoveWatch();
        ModalDialogEventHandler = ModalDialogRemoveWatch();

	    var popup = document.getElementById("ctl00_rightContainer_CB3");
		popup.Show('LightBlue');
		var div = document.getElementById("divImage");
		div.style.backgroundColor = 'LightBlue';
		
		ctr = 1;
		ctrMax = 100;
		var intervalId;
		intervalId = setInterval("UpdateIndicator(ctr, ctrMax)", 1000);
		  
		ModalDialogInterval = setInterval("ModalDialogMaintainFocus()",5);
	}
    function End()
    {
        var popup = document.getElementById("ctl00_rightContainer_CB3");
	    popup.Hide();
    }
	
     function UpdateIndicator(curCtr, ctrMaxIterations)
     {
        if (document.getElementById("loading").value != "waiting")
	            End();

	    curCtr += 1;
//	    ProgressBar();
     }
//     var n = 0;
//     function ProgressBar()
//     {           
//         var incr = 200 / 2;   
//         incr = 5;
//         var innerDiv = document.getElementById("innerDiv");
//         total = total + incr;
//         var pixel = total;
//         if(n % 2 == 0)
//         {
//            innerDiv.style.backgroundColor = "LightBlue";
//            innerDiv.style.width = pixel;
//            n += 1;alert("%");
//         }
//         else
//         {
//            innerDiv.style.backgroundColor = "blue";
//            innerDiv.style.width = pixel;
//            n += 1;alert("/");
//         }         
//     }

//...new popup bar...//////



var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write(t);
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;
bA.showBar=function(){
this.bar.style.visibility="visible";
}
bA.hideBar=function(){
this.bar.style.visibility="hidden";
}
bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
t.style.left=-(t.h*2+1)+'px';
t.ctr++;
if(t.ctr>=t.count){
eval(t.action);
t.ctr=0;
}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}