﻿// JScript File

  String.prototype.trim = function () 
    {
    return this.replace(/^\s*/, "").replace(/\s*$/, ""); 
    }

 function noCopyMouse(e) 
        {
		    if (event.button == 2 || event.button == 3)
		     {			    
			    return false;
		     }
		    return true;
	    }
	


	   function noCopyKey(e)
	    {	   
                var forbiddenKeys = new Array('c','x','v');
	            var isCtrl;

                    if(window.event)
                    {
		            if(window.event.ctrlKey)
			            isCtrl = true;
		            else
			            isCtrl = false;
                    }
                    else
                    {
                            if(e.ctrlKey)
                	            isCtrl = true;
                            else
                	            isCtrl = false;
                	}

	            if(isCtrl)
	             {
		            for(i=0; i < forbiddenKeys.length; i++)
		             {
			            if(forbiddenKeys[i] == String.fromCharCode(window.event.keyCode).toLowerCase())
			             {				            
				            return false;
			             }
        		     }
	            }	    
           }
          	
       function TextOnly()
            {            
	            var AsciiValue=event.keyCode              
	            if((AsciiValue>=96 && AsciiValue<=122) || (AsciiValue>=64 && AsciiValue<=90) || (AsciiValue==8 || AsciiValue==127 || AsciiValue==32))
	                  event.returnValue=true;
		        else
		              event.returnValue=false;	            
            }
            
    function NumberOnly()
        {
           var AsciiValue=event.keyCode
           
	        if((AsciiValue>=48 && AsciiValue<=57) || (AsciiValue==8 || AsciiValue==127))
		        event.returnValue=true;
		    else
		        event.returnValue=false;
        }
        
        /// add by manish on 25 october 2008
        function TextOnlyWithSpecialChars()
    {
     var AsciiValue=event.keyCode              
	            if((AsciiValue>=96 && AsciiValue<=122) || (AsciiValue>=64 && AsciiValue<=90) || (AsciiValue==8 || AsciiValue==127 || AsciiValue==32 || AsciiValue==46 || AsciiValue==40 || AsciiValue==41 || AsciiValue==38 || AsciiValue==45 || AsciiValue==47))
	                  event.returnValue=true;
		        else
		              event.returnValue=false;	
    }  
    
    
    function ClearAllOnMasterPage()
{
         for(i = 0; i < document.forms['aspnetForm'].length ; i++)
         {
         var elm = (document.forms['aspnetForm'].elements[i]);
         if (elm.type == 'text')
         elm.value = '';
         if (elm.type == 'select-one')
         elm.selectedIndex = 0;
         if (elm.type == 'checkbox')
         elm.checked = false;
         }
return false;
}


   //Manisha added on 25 nov 2008
        function NumberOnlyWithDash()
        {
           var AsciiValue=event.keyCode
	        if((AsciiValue>=48 && AsciiValue<=57) || (AsciiValue==8 || AsciiValue==127 || AsciiValue==45) )
		        event.returnValue=true;
		    else
		        event.returnValue=false;
        }




 //Manisha on 18nov 2008
    function TextSpecialCharswithComma()
    {
     var AsciiValue=event.keyCode              
	            if((AsciiValue>=96 && AsciiValue<=122) || (AsciiValue>=64 && AsciiValue<=90) || (AsciiValue==8 || AsciiValue==127 || AsciiValue==32 || AsciiValue==46 || AsciiValue==40 || AsciiValue==41 || AsciiValue==38 || AsciiValue==45 || AsciiValue==47 || AsciiValue==44))
	                  event.returnValue=true;
		        else
		              event.returnValue=false;	
    }  
    
    
// Date Validation ( From Date Should Be Less Then To Date -  )
// First Argument - From Date
// Second Argument - To Date
// Third Argument - Span id
// How To Use - On Page Load Write Following Line & Change Argument
// btnSubmit.Attributes.Add( "OnClick", "ValidateCurruntDate('" + txtFromDate.ClientID + "','" + txtToDate.ClientID + "', 'Error', 'Message')" );


function ValidateDate( From, To, Error, Message )
{
   t1 = document.getElementById (To).value ;
   t2 = document.getElementById (From).value ; 
   
   if ( t1 != "" && t2 != "" )
   {
      var one_day = 1000 * 60 * 60 * 24;
      var x = t1.split( "/" );
      var y = t2.split( "/" );
      var date1 = new Date( x[2], ( x[1] - 1 ), x[0] );
      var date2 = new Date( y[2], ( y[1] - 1 ), y[0] )
      // Calculate difference between the two dates, and convert to hours
      _Diff = Math.ceil( ( date2.getTime() - date1.getTime() ) / ( one_day ) );

      var flag = true;

      if( _Diff > 0 )
      {
         document.getElementById( Error ).innerHTML = Message;
         flag = false;
      }
      return flag;
   }
}

function ValidateCurruntDate( From, To, Error, Message )
{
   t1 = To;
   t2 = document.getElementById (From).value ; 
   
   if ( t1 != "" && t2 != "" )
   {
      var one_day = 1000 * 60 * 60 * 24;
      var x = t1.split( "/" );
      var y = t2.split( "/" );
      var date1 = new Date( x[2], ( x[1] - 1 ), x[0] );
      var date2 = new Date( y[2], ( y[1] - 1 ), y[0] )
      // Calculate difference between the two dates, and convert to hours
      _Diff = Math.ceil( ( date2.getTime() - date1.getTime() ) / ( one_day ) );

      var flag = true;

      if( _Diff > 0 )
      {
         document.getElementById( Error ).innerHTML = Message;
         flag = false;
      }
      return flag;
   }
}
////////////////////////
// Function Created For Inserting Float Value In Text Box
// by Anudeep Jaiswal 22-Dec-2008  
function FloatOnly( Textbox )
{
   var tt = document.getElementById( Textbox.id ).value;

   var pressed = tt.indexOf( ".", 0 );

   if ( pressed == - 1 )
   point_pressed = false;
   else
   {
      var DecimalLength = tt.indexOf( '.' );
      var TextLength = tt.length;
      point_pressed = true;
      if ( ( TextLength -  DecimalLength ) == 3 )
      {
         return false;
      }
   }


   var AsciiValue = event.keyCode
   if( ! ( ( event.keyCode >= 48 && event.keyCode <= 57 ) || ( event.keyCode == 46 && ! point_pressed ) ) )
   {
      event.returnValue = false;
   }
}

// Text Counter

// Dynamic Version by: Nannette Thacker -->
// http://www.shiningstar.net -->
// Original by :  Ronnie T. Moore -->
// Web Site:  The JavaScript Source -->
// Use one function for multiple text areas on a page -->
// Limit the number of characters per textarea -->

 function textCounter(field,cntfield,maxlimit) {
 
 cntfield = document.getElementById( cntfield )
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.innerHTML = maxlimit - field.value.length + " Character Left";
}//



// Clear All On Master Page
// Either Simple Or Ajax Enable Page OnClientClick

function ClearAllOnMasterPage()
{
   for( i = 0; i < document.forms['aspnetForm'].length ; i ++ )
   {
      var elm = ( document.forms['aspnetForm'].elements[i] );
      if ( elm.type == 'text' )
      elm.value = '';
      if ( elm.type == 'select-one' )
      elm.selectedIndex = 0;
      if ( elm.type == 'checkbox' )
      elm.checked = false;
      if ( elm.type == 'textarea' )
      elm.value = '';
   }
   return false;
}




function AlertOnDelete(Button)
 {
   msg = "Are you sure you want to delete this?";
   if (confirm(msg))
   {   
   document.getElementById(Button.id).setAttribute("value","yes");
   }
   else
   return false;
 }
 
 function showhint(divcontent, alink, xpos, ypos)
{
   divid = "tooltip_id";
   var prev = "";
   if(prev != "" && prev != divid)
   {
      var pobj = document.getElementById(prev);
      pobj.style.display = "none"
   }
   if((divcontent == "divtooltips_adv") && (document.getElementById("clickToCall")))
   {
      document.getElementById(divid).innerHTML = document.getElementById("clickToCall").innerHTML
   }
   else
   {
      if((divcontent == "divtips") && (document.getElementById("divtips_Adres")))
      {
         document.getElementById(divid).innerHTML = document.getElementById("divtips_Adres").innerHTML
      }
      else
      {
         document.getElementById(divid).innerHTML = divcontent
      }
   }
   prev = divid;
   var xCord = - 8;
   var yCord = - 5;
   var obj = document.getElementById(divid);
   var iframeObj = document.getElementById("tooltip_frame");
   var cord = getAnchorPosition(alink);
   if(navigator.appName == "Netscape")
   {
      cord.y = cord.y + (ypos + yCord);
      cord.x = cord.x + (xpos + xCord)
   }
   else
   {
      cord.y = cord.y + ypos;
      cord.x = cord.x + xpos
   }
   obj.style.top = eval("'"+cord.y+"px'");
   obj.style.left = eval("'"+cord.x+"px'");
   obj.style.visibility = "visible";
   obj.style.display = "block";
   obj.style.zIndex = "100000"
}

function getAnchorPosition(B)
{
   var E = false;
   var J = new Object();
   var I = 0, G = 0;
   var D = false, F = false, H = false;
   if(document.getElementById)
   {
      D = true
   }
   else
   {
      if(document.all)
      {
         F = true
      }
      else
      {
         if(document.layers)
         {
            H = true
         }
      }
   }
   if(D && document.all)
   {
      I = AnchorPosition_getPageOffsetLeft(document.all[B]);
      G = AnchorPosition_getPageOffsetTop(document.all[B])
   }
   else
   {
      if(D)
      {
         var A = document.getElementById(B);
         I = AnchorPosition_getPageOffsetLeft(A);
         G = AnchorPosition_getPageOffsetTop(A)
      }
      else
      {
         if(F)
         {
            I = AnchorPosition_getPageOffsetLeft(document.all[B]);
            G = AnchorPosition_getPageOffsetTop(document.all[B])
         }
         else
         {
            if(H)
            {
               var K = 0;
               for(var C = 0; C < document.anchors.length; C ++ )
               {
                  if(document.anchors[C].name == B)
                  {
                     K = 1;
                     break
                  }
               }
               if(K == 0)
               {
                  J.x = 0;
                  J.y = 0;
                  return J
               }
               I = document.anchors[C].x;
               G = document.anchors[C].y
            }
            else
            {
               J.x = 0;
               J.y = 0;
               return J
            }
         }
      }
   }
   J.x = I;
   J.y = G;
   return J
}

function AnchorPosition_getPageOffsetLeft(B)
{
   var A = B.offsetLeft;
   while((B = B.offsetParent) != null)
   {
      A += B.offsetLeft
   }
   return A
}
 function AnchorPosition_getPageOffsetTop(A)
{
   var B = A.offsetTop;
   while((A = A.offsetParent) != null)
   {
      B += A.offsetTop
   }
   return B
}
 
function hideToolTip()
{
   var A = document.getElementById("tooltip_id");
   A.style.display = "none"
}