// JScript File
 function ValidateNumeric(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
       
         if (charCode > 31 &&  (charCode < 48 || charCode > 57 ))
             return false;
         return true;
      }  

//Added By Amar On 10 Oct 2009'For Numbers and Dot
function ValidateNumericAndDot(evt,id)
{
    var charCode=''; //= (evt.which) ? evt.which : event.keyCode      
      
    if(window.event) // IE
    {
        charCode = event.keyCode;
        //alert(charCode);
        if((charCode>=48 && charCode<=57) || charCode==46 || charCode == 8)
        {
        
              if (charCode==46)
              {
               
                   var patt1=new RegExp("\\.");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        window.event.returnValue = false;
                   }
                   else
                   {
                        window.event.returnValue = true;
                   }                        
            }
         
        }
        else
        {
         window.event.returnValue = false;
        }
    }
    else if(evt.which) // Netscape/Firefox/Opera
    {
        charCode = evt.which;
        // alert(charCode);
        if((charCode>=48 && charCode<=57) || charCode==46 || charCode == 8)
        {
              if (charCode==46)
              {  
                   var patt1=new RegExp("\\.");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        return false;
                   }
                   else
                   {
                        return true;
                   }                        
            }
        }
        else
        {
        return false;
        }
    }
}
function ValidateNumericAndDotAndDash(evt,id)
{
    var charCode=''; //= (evt.which) ? evt.which : event.keyCode      
      
    if(window.event) // IE
    {
        charCode = event.keyCode;
        //alert(charCode);
        if((charCode>=48 && charCode<=57) || charCode==46 || charCode==45)
        {
        
              if (charCode==46)
              {
               
                   var patt1=new RegExp("\\.");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        window.event.returnValue = false;
                   }
                   else
                   {
                        window.event.returnValue = true;
                   }                        
            }
            if (charCode==45)
              {
               
                   var patt1=new RegExp("\\-");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        window.event.returnValue = false;
                   }
                   else
                   {
                        window.event.returnValue = true;
                   }                        
            }
         
        }
        else
        {
         window.event.returnValue = false;
        }
    }
    else if(evt.which) // Netscape/Firefox/Opera
    {
        charCode = evt.which;
        // alert(charCode);
        if((charCode>=48 && charCode<=57) || charCode==46 || charCode==45)
        {
              if (charCode==46)
              {  
                   var patt1=new RegExp("\\.");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        return false;
                   }
                   else
                   {
                        return true;
                   }                        
            }
            if (charCode==45)
              {  
                   var patt1=new RegExp("\\-");
                   var field=document.getElementById(id).value;     
                   var ch =patt1.exec(field);       
                   if(ch==".")
                   {
                        return false;
                   }
                   else
                   {
                        return true;
                   }                        
            }
        }
        else
        {
        return false;
        }
    }
}

 

function ValidateAlphaNumericNew(evt)
{
        var keyCode = (evt.which) ? evt.which : event.keyCode
        if ((keyCode > 47 && keyCode < 58)||(keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || keyCode==46 || keyCode==95 ||  keyCode==32 ||  keyCode==8)
        {
            return true;
            
        }
        else
        {
            return false;
        }
}
 function ValidateAlphaNumericNew1(evt)
{
        var keyCode = (evt.which) ? evt.which : event.keyCode
        
        if ((keyCode > 31 && keyCode < 65)||(keyCode >= 65 && keyCode <= 96) || (keyCode >= 97 && keyCode <= 126) || keyCode==46 || keyCode==95 ||  keyCode==32 )
        {
            return false;
            
        }
        else
        {
            return true;
        }
}
 
       
function ValidateNumericNew(evt)
{
   var charCode=''; //= (evt.which) ? evt.which : event.keyCode      
      
    if(window.event) // IE
    {
        charCode = event.keyCode;
        //alert(charCode);
        if((charCode>=48 && charCode<=57))
        {
         window.event.returnValue = true;
        }
        else
        {
         window.event.returnValue = false;
        }
    }
    else if(evt.which) // Netscape/Firefox/Opera
    {
        charCode = evt.which;
        // alert(charCode);
        if((charCode>=48 && charCode<=57))
        {
        return true;
        }
        else
        {
        return false;
        }
    }
}  
      
         
            

function ValidateAlphabet()
{
    var keyCode = window.event.keyCode;
    if ((keyCode > 96 && keyCode < 123) || (keyCode > 64 && keyCode < 91))
    {
    window.event.returnValue = true;
    }
    else
    {
     window.event.returnValue = false;
    }
}
function ValidateAlphaNumeric(e)
{
    if(e.altKey  || e.shiftKey)
        return false;        
    else if(e.which) // Netscape/Firefox/Opera
    {
        charCode = e.which;
        // alert(charCode);
    if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123))
        {
        return true;
        }
    else
            return false;
    }
    else if(window.event) // IE
    {
        charCode = e.keyCode;
        if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123))
        {
        return true;
        }
         else
            return false;
    }
}
function ValidateAlphaNumericRoll(e, rollid)
{
    if(e.altKey  || e.shiftKey)
        return false;      
    else if(e.which) // Netscape/Firefox/Opera
    {
        charCode = e.which;
         if(rollid != 3 && rollid != 4)
         {  
             if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123) || charCode == 44 || charCode == 8)
             {
                  return true;
              }
             else
                 return false;              
          }
         else
         {
             if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123) || charCode == 8)
             {
                  return true;
             }
             else
                 return false;              
         
          }
     }      
    else if(window.event) // IE
    {
        charCode = e.keyCode;
                if(rollid != 3 && rollid != 4)
         {  
             if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123) || charCode == 44 || charCode == 8)
             {
                  return true;
              }
             else
                 return false;              
          }
         else
         {
             if ((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode > 96 && charCode<123) || charCode == 8)
             {
                  return true;
             }
             else
                 return false;              
         
          }

    }
}
function allowpesting(e, rollid)
{
   
     if(e.which) // Netscape/Firefox/Opera
    {
           if(rollid != 3 && rollid != 4)
                return true;
           else
                 return false;              
       
     }      
    else if(window.event) // IE
    {
           if(rollid != 3 && rollid != 4)
                return true;
           else
                 return false;  
    }
    
}



function ValidateAlphaNumSplChar(e)
{

var charCode='';
if(e.which || window.event) // Netscape/Firefox/Opera
    {
        
        charCode =  (e.which) ? e.which : event.keyCode
 
//    var keyCode = (evt.which) ? evt.which : event.keyCode
    //alert(keyCode);
         if (charCode==39 || charCode==60 || charCode==62 || charCode==32)
            {
                return false;
//              window.event.returnValue =
            }
         else
            {
               return true;
//              window.event.returnValue =
             }
     }
    
   else if(window.event) // Netscape/Firefox/Opera
    {
         charCode =  window.event;
//    var keyCode = (evt.which) ? evt.which : event.keyCode
    //alert(keyCode);
        if (charCode==39 || charCode==60 || charCode==62 || charCode==32)
        {
            return false;
//         window.event.returnValue =
         }
         else
         {
             return true;
//         window.event.returnValue =
          }
     }
}           
           
           
           
function checkPasswordLength()
{
    var password=document.getElementById("txtPassword01").value;
    if(password.length == 0)
    {
    return false;
    }
    else
    {    
        if(password.length < 5)
        {
            document.getElementById("txtPassword01").focus();
            document.getElementById("txtPassword01").value="";                                   
            alert("Please enter minimum 5 characters for password.");                    
            return false;
        }
        else
        {
        return true;
        }
    }
    
}
            
//SOLANKI JAYANT H.
//09-01-2009
//TO CHECK ENTERED EMAIL ADDRESS FORMAT IS VALID OR NOT...
function checkEmail(emailAddress)
{
     var testresults     
     var filter=/^.+@.+\..{2,3}$/

     if (filter.test(emailAddress))
        testresults=true
     else 
     {
        alert("Please enter a valid email address.")
        testresults=false
     }
 return testresults;
}
//Solanki Jay 
//26-12-2008
//CHECK DOMAIN NAME AFTER LOST FOCUS FROM WEB SITE TEXTBOX...
 function checkDomain(website)
 {
    var domain = document.getElementById(website).value    
    if (domain != '')
    {
                    var arr = new Array(
                '.com','.net','.org','.biz','.coop','.info','.museum','.name',
                '.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
                '.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
                '.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
                '.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
                '.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
                '.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
                '.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
                '.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
                '.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
                '.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
                '.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
                '.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
                '.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
                '.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
                '.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
                '.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
                '.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
                '.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
                '.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
                '.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
                '.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
                '.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
                '.wf','.ye','.yt','.yu','.za','.zm','.zw');

                var domainText = domain;
                var val = true;
                //Retrieve last dot index value....
                var dot = domainText.lastIndexOf(".");
                //Retrieve domain name aftrer truncate all character after last dot....
                var dname = domainText.substring(0,dot);
                //Retrieve extension name after last dot....
                var ext = domainText.substring(dot,domainText.length);

                //alert(ext);
                	
                if(dot>2 && dot<57)
                {
                    // loop to check valid extension available in array.
	                for(var i=0; i<arr.length; i++)
	                {
	                  if(ext == arr[i])
	                  {
	 	                val = true;
		                break;
	                  }	
	                  else
	                  {
	 	                val = false;
	                  }
	                }
	                if(val == false)
	                {
	  	                 alert("Your domain extension "+ext+" is not correct");
	  	                 document.getElementById("txtWebsite").focus();
	  	                 return false;
	                }
	                else
	                {
	                    //extension is valid then loop to check any special character is used in domain name..
		                for(var j=0; j<dname.length; j++)
		                {
		                  var dh = dname.charAt(j);
		                  var hh = dh.charCodeAt(0);
                		  
		                  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		                  {
		                    //Check first and last position of domain is hyphan(-)...
			                 if((j==0 || j==dname.length-1) && hh == 45)	
		  	                 {
		 	  	                 alert("Domain name should not begin or end with '-'");
		 	  	                 document.getElementById("txtWebsite").focus();
			                     return false;
		 	                 }
		                  }
		                  else
		                  {
		                    // Check if hh having _ (underscore) then continue looping....
		                     if(hh == 95)
		                     {
		                        continue;
		                     }
		                     else
		                     {
		  	                    alert("Your domain name should not have special characters");
    	  	                    document.getElementById("txtWebsite").focus();
			                    return false;
		                     }	 
		                  }
		                }
	                }
                }
                else
                {
                 alert("Your domain name is too short/long");
                 document.getElementById("txtWebsite").focus();
                 return false;
                }	
        }//END FIRST IF ...
        return true;
}


//function printpage(strid)
// {
//	   var prtContent = document.getElementById(strid);
//       var WinPrint='' ;
//       WinPrint = window.open('','','width=10,height=10,left=0,top=1000,screenX=0,screenY=0');
//       WinPrint.document.write('<link href="../App_Themes/RosyTheme/Rosy.css" rel="stylesheet" type="text/css" />');
//       winPrint.document.write('<link href="../css/newdesign.css" media="all" rel="stylesheet" type="text/css" />');
//       WinPrint.document.write('<style type="text/css">@media print { .noPrint { display: none; }}</style>');
//       
//       //WinPrint.document.write('<div align="Center"><b>RB One Source</b></div><br>');
//       WinPrint.document.write(prtContent.innerHTML);
//       WinPrint.document.close();
//       WinPrint.focus();
//       WinPrint.print();
//       WinPrint.close();
//       return false;
// }
             
//JAYANT SOLANKI
//31-01-2009
// Enter only digit or allowed to enter decimal point.. 
//Pass decOK for allowe decimal. pass decNo for only digit no decimal point...
//function onlyDigits1(e,decReq) 
//{
//var key = window.event.keyCode;
//var obj = event.srcElement;
//var isNum = (key > 47 && key < 58) ? true:false;
//var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
//if(key < 32)
//{
//  return true;
//}
//else
//{
//    return (isNum || dotOK);
//}
//} 
             
             //---------Customised Alert Msg in Javascript -------------------------------
             
/*var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	// shortcut reference to the document object
	d = document;

	// if the modalContainer object already exists in the DOM, bail out.
	if(d.getElementById("modalContainer")) return;

	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.documentElement.scrollHeight + "px";

	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	// center the alert box
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

	// create an H1 element as the title bar
	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	// create a paragraph element to contain the txt argument
	msg = alertObj.appendChild(d.createElement("p"));
	msg.innerHTML = txt;
	
	// create an anchor element to use as the confirmation button.
	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	// set up the onclick event to remove the alert when the anchor is clicked
	btn.onclick = function() { removeCustomAlert();return false; }

	
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}*/

/*commented by shradha on date 31 Oct 2009*/
///Attaching a function on window.onload event.
    window.onload = function()
    {
        var strCook = document.cookie; 
        if(strCook.indexOf("!~")!=0)
        { 
            var intS = strCook.indexOf("!~"); 
            var intE = strCook.indexOf("~!"); 
            var strPos = strCook.substring(intS+2,intE); 
            window.scrollTo(0,strPos);
        } 
    }
    /// Function to set Scroll position of page before postback. 
    function SetScrollPosition()
    { 
        var ScrollTop = document.body.scrollTop;
        if (ScrollTop == 0)
        {
            if (window.pageYOffset)
                ScrollTop = window.pageYOffset;
            else
                ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        }
        var intY = ScrollTop; 
        document.cookie = "yPos=!~" + intY + "~!"; 
    }
    /// Attaching   SetScrollPosition() function to window.onscroll event.
    window.onscroll = SetScrollPosition;


function getCompareCheckedDetails(index,result,datagridname) 
{ 
    var id=datagridname+ "__ctl" + (index+1) + "_chkSubmitSelect"; 
    if(document.getElementById(id)) 
    { 
        if(document.getElementById(id).checked==true) 
        {
            result="F";
        } 
        if(result=="F") 
        { 
            return result;
        } 
        else 
        { 
            index=index+1; 
            result=getCompareCheckedDetails(index,result,datagridname);
        }
    } 
    return result;
} 
function fnSelectCompare() 
{

    var resultL1 = getCompareCheckedDetails(2,'T','dgSearchResults'); 
    if(resultL1=="T")
    {
        alert('<%= Resources.Resource.alertSelectatleast1chkbx%>');
        return false; 
    }
}

// Solanki Jayant H.
// 18/10/2008		 
function checkSelected(id)
{    

    var count=document.getElementById("txtCount").value;  
    var chk = document.getElementById(id);         
    if(chk.checked == true)
    { 
        document.getElementById("txtCount").value = parseInt(document.getElementById("txtCount").value)  + 1;         
    }
    else
    {    
        document.getElementById("txtCount").value = parseInt(document.getElementById("txtCount").value) - 1;
    }    
    if(document.getElementById("txtCount").value > "4")
    {
        alert('<%= Resources.Resource.alertselectlessthan4%>');
        document.getElementById("txtCount").value = parseInt(document.getElementById("txtCount").value) - 1;        
        return false;
    }

}

function GetEachStockNumbers(index,result,datagridname)
{

    var id="";
    if(index<9)
    {
        id=datagridname+ "_ctl0" + (index+1) + "_chkOrderSelect";
    }
    else
    {
        id=datagridname+ "_ctl" + (index+1) + "_chkOrderSelect";
    }
    if(document.getElementById(id)) 
    { 
        if(document.getElementById(id).checked==true) 
        {
            var lotid="";
            if(index<9)
            {
                lotid=datagridname+ "_ctl0" + (index+1) + "_lblShape1";
            }
            else
            {
                lotid=datagridname+ "_ctl" + (index+1) + "_lblShape1";
            }

            if(result=='')
            {
                result=document.getElementById(lotid).innerHTML;
            }
            else
            {
                result=result+','+document.getElementById(lotid).innerHTML;
            }
        } 

        index=index+1; 
        result=GetEachStockNumbers(index,result,datagridname);
    } 
    return result;
}

//Jayant Solanki
//09-12-2008
function selectAll()
{
    var txtSearch = document.getElementById("txtSearch");
    txtSearch.focus();
    txtSearch.select();
    return false;
}



function redirect_page(lotno,loginID,intPageSize,strData,strFormName)
{ 		   
    window.location.href='ViewDiamond.aspx?invID=' + lotno + '&loginID=' + loginID + '&PageSize=' + intPageSize + '&Data=' + strData + '&from=' + strFormName;		    
}


/*Check for a special character'***/
function isSplChar(str)
{
    var spchar, getChar, SpecialChar;		
    spchar="`()(\\~!@^&*+\"|%:=,<>?";	
    getChar='Empty';	
    SpecialChar='No';	
    	
    var spchars ="`()\\~!@^&*+\"|:=,<>?"; 	
    var strlength = str.length;
    
    for(var i=0; i<strlength;i++)
    {	for(var j=0; j < spchar.length ; j++)
        {	
            if(str.charAt(i)== spchar.charAt(j))			
            {				
                SpecialChar='Yes';
				break;			
            }
            else			
            {				
                if (str.charAt(i)!=' ')				
                    getChar='Normal';			
            }		
            
        }			
    }	
    if (SpecialChar == 'Yes')	
    {		
        alert('Please do not enter any of the following characters: \n ' + spchars);			
        return false;	
    }	
    else if (SpecialChar == 'No')	
    {		
        return true;	
    }
}






