﻿// JScript File

// For Print //
 function printpage(strid)
            {
   
                 var prtContent = document.getElementById(strid);
      
                  var WinPrint = window.open('','','width=10,height=10,left=0,top=1000,screenX=0,screenY=0');
                  //WinPrint.document.write('<link href="../css/rosy.css" rel="stylesheet" type="text/css" />');
                  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;
            }
            
function ValidateNumeric()
            {//alert('hi');
                var keyCode = window.event.keyCode;

                if (keyCode > 57 || keyCode < 48)

                window.event.returnValue = false;
            }
            
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(website).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(website).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(website).focus();
			                    return false;
		                     }	 
		                  }
		                }
	                }
                }
                else
                {
                 alert("Your domain name is too short/long");
                 document.getElementById(website).focus();
                 return false;
                }	
        }//END FIRST IF ...
        return true;
}



function ValidateAlphabetOld(e)
{
var keynum;
var keychar;
var numcheck;

if(window.event) // IE
  {
  keynum = e.keyCode;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
  }
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return !numcheck.test(keychar);
}

function ValidateAlphabet(e)
{
var keynum;
var keychar;
var numcheck;

if(window.event) // IE
  {
  keynum = e.keyCode;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
  }
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
//alert(keychar);
//alert(numcheck.test(keychar));
if (numcheck.test(keychar))
{
    
    return false;
}
else
{//alert(keynum);
    if (keynum==60 || keynum==62)
    {
        return false;
    }
    else
    {
        return true;
    }
    
}
//return !numcheck.test(keychar);

}


function ValidateNumeric(evt)
      {//alert('evt');
         var charCode = (evt.which) ? evt.which : event.keyCode
//         alert(charCode);
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }  
      
function ValidateNumericForLessGreaterSign(evt)
      {//alert('evt');
         var charCode = (evt.which) ? evt.which : event.keyCode
//         alert(charCode);
         if (charCode == 60 || charCode == 62)
            return false;

         return true;
      }  
function ValidateNumericForLessGreaterHyphenSign(evt)
      {//alert('evt');
         var charCode = (evt.which) ? evt.which : event.keyCode
//         alert(charCode);
         if (charCode == 60 || charCode == 62 || charCode == 45)
            return false;

         return true;
      }  
      
    //Ckeck Box Validation /////
    function ValidateNegativeNumeric(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode != 45 && (charCode < 48 || charCode > 57)))
            return false;

         return true;
      }  
    
function validate() 
{ 
// Checking if at least one period button is selected. Or not. 
//if (!document.form1.sex[0].checked && !document.form1.sex[1].checked){ 

//alert("Please Select Sex"); 
//return false;}



var check =document.getElementById('chktermcondition').value
  if (check.checked= False)
  {
alert("Please Read the guidelines and check the box below"); 
return false; 
}
else
{
return true;
}

}
 

// JScript File for TextArea
// Keep user from entering more than maxLength characters
function doKeypressOld(control,len){
//    maxLength = control.attributes["maxLength"].value;
    
    maxLength = len;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}

function doKeypress(control,len,e){
//    maxLength = control.attributes["maxLength"].value;
    
    maxLength = len;
    value = control.value;
     var charCode = (e.which) ? e.which : event.keyCode
//     alert(charCode);
     if (charCode==60 || charCode==62)
     {
        event.returnValue = false;
     }
     else
     { 
         if(maxLength && value.length > maxLength-1){
              event.returnValue = false;
              maxLength = parseInt(maxLength);
         }
     }
}

// Cancel default behavior
function doBeforePaste(control,len){
    maxLength = len;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control,len){
    maxLength = len;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}
function ValidateNumericdoBeforePaste(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }  
      
      
function ValidateAlphaNumeric1(evt)
      {//alert('evt');
         var charCode = (evt.which) ? evt.which : event.keyCode
         //alert(charCode);
         if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
            return false;

         return true;
      }  
      
      