/* JavaScript Document
All source in this document is created by sartaj singh. This is copyrighted. You can not use this source without permission.
Contact sartaj on mobile +919872833288 or email  sartaj_singh_randhawa@rediffmail.com, info@sartajsingh.com
*/






function validateAdminForm(){
	alert("Harpal");
var txtuserID = document.getElementById('txtuserID');
	if(txtuserID == ""){
	 alert("Please fill User Id");
	}
	else{
		document.form1.submit();
	}
}// end of function

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkEmail(e)
{
val1 = e;

var returnval=emailfilter.test(val1);
if (returnval==false)
{
alert("Please enter a valid email address.");
}
return returnval;
}


function combobox(e,f)
{



val1 = e;
val2=f;
returnval=true;
if (e==f)
    {
    returnval=false;
    }
if (returnval==false)
{
alert("Please " + f);
}
return returnval;
}



function ContactNo(t)
{
var patt = /(\d*)\.{1}(\d{0,2})/;
var donepatt = /^(\d*)\.{1}(\d{2})$/;
var str = t.value;
var result;
if (!str.match(donepatt))
{
result = str.match(patt);
if (result!= null)
{
t.value = t.value.replace(/[^\d]/gi,'');
str = result[1] + '.' + result[2] ;
t.value = str;
}else{
if (t.value.match(/[^\d]/gi))
t.value = t.value.replace(/[^\d]/gi,'');}
}
}


function checkTextEmpty(ctlText){
var obj1;
var val1;
var returnval = true;

// var ctlText = Array('txtuserID', 'User ID');
for(var c=0; c < ctlText.length; c++){
obj1 = document.getElementById(ctlText[c]);
val1 = obj1.getAttribute('value');
if(val1 == ''){
// for firefox
val1 = obj1.value;
}
//val1 = val1.trim();
c++;
if(val1 == ''){
returnval = false;
alert(ctlText[c] + " can not Empty");
obj1.focus();
break;
}

}
return returnval;

}

function checkemails(ctlText){
var obj1;
var val1;
var returnval = true;

// var ctlText = Array('txtuserID', 'User ID');
for(var c=0; c < ctlText.length; c++){
obj1 = document.getElementById(ctlText[c]);
val1 = obj1.getAttribute('value');
if(val1 == ''){
// for firefox
val1 = obj1.value;
}
//val1 = val1.trim();
c++;
if(checkEmail(val1)==false ){
returnval = false;
obj1.focus();
break;
}

}
return returnval;

}

function checknums(ctlText){
var obj1;
var val1;
var returnval = true;

// var ctlText = Array('txtuserID', 'User ID');
for(var c=0; c < ctlText.length; c++){
obj1 = document.getElementById(ctlText[c]);
val1 = obj1.getAttribute('value');
if(val1 == ''){
// for firefox
val1 = obj1.value;
}
//val1 = val1.trim();
c++;
if(validNum(val1)==false ){
returnval = false;
obj1.focus();
break;
}

}
return returnval;

}


// pass the HTML element return the x, y position
function getPos(zxcobj){
zxclft=zxcobj.offsetLeft;
zxctop=zxcobj.offsetTop;
while(zxcobj.offsetParent!=null){
zxcpar=zxcobj.offsetParent;
zxclft+=zxcpar.offsetLeft;
zxctop+=zxcpar.offsetTop;
zxcobj=zxcpar;
}
return [zxclft,zxctop];
}

var message="Sorry, This Site is Protected By Randhawa Tech.\n\nContents & Graphics Copyright ?\ should NOT be taken from this site."; // Message for the alert box

function protectRightClick(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}

function validNum(e)
{
sText = e;
   var ValidChars = "-0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
	  //alert(i);
      Char = sText.charAt(i);
	  //alert(ValidChars.indexOf(Char));
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
     alert("Please enter a valid Number.");
        break;
         }
      }

   return IsNumber;


   }



// document.onmousedown = protectRightClick;

