function checkAll(obj, oAll) {
	if(oAll){
		for (var i=0; i<obj.length;i++)
			obj[i].checked = oAll.checked;
	}
	else{
		var b = true;
		var i = 0;
		while(i < obj.length && b){
			b = obj[i].checked;
			i++;
		}
		document.getElementById("id" + obj[0].name).checked = b;
	}		
}


function Check_box(obj_Form,lc_Name,err_msg)
{
	i = 0; 
	b = obj_Form.elements[lc_Name][i].checked;
	while( !b && i<=obj_Form.elements[lc_Name].length-1){
		b = obj_Form.elements[lc_Name][i].checked;
		i++;
	}
	if(!b) {
		alert('Please select some '+err_msg+' to proceed.')
	}
	return b;
}


function fillList(lst1, lst2, xmlpage, cValue, cID){
	var http = (window.ActiveXObject)? new ActiveXObject("MSXML2.XMLHTTP"): new XMLHttpRequest;
	var sUrl = xmlpage + "?r=" + Math.random() + "&id=" + lst1.value;
	http.open("GET", sUrl, false, null, null);
	http.send(null);
	var xml = http.responseXML;
	var opt = lst2.options;
	opt.length = 1;
	if(window.ActiveXObject){
		xml.setProperty("SelectionLanguage", "XPath");
		var data = xml.selectNodes("//recordset/record");
		for( var k=0; data.length > k; k++){
			var nID = data[k].selectSingleNode(cID);
			var nValue = data[k].selectSingleNode(cValue);
			opt[opt.length] = new Option(nValue.firstChild.nodeValue, nID.firstChild.nodeValue);
		}
	}
	else{
		var xpath = new window.XPathEvaluator;
		var data = xpath.evaluate("//recordset/record", xml, null, 7, null);
		for(var k = 0; data.snapshotLength > k; k++){
			var nID = xpath.evaluate( cID, data.snapshotItem(k), null, 9, null).singleNodeValue;
			var nValue = xpath.evaluate( cValue, data.snapshotItem(k), null, 9, null).singleNodeValue;
			opt[opt.length] = new Option(nValue.firstChild.nodeValue, nID.firstChild.nodeValue);
		}
	}
}

function fillText(tmk, tmod, xmlpage, eValue, eID){
	var http = (window.ActiveXObject)? new ActiveXObject("MSXML2.XMLHTTP"): new XMLHttpRequest;
	var sUrl = xmlpage + "?r=" + Math.random() + "&mkid=" + tmk.value + "&modid=" + tmod.value;
	http.open("GET", sUrl, false, null, null);
	http.send(null);
	var xml = http.responseXML;
	if(window.ActiveXObject){
		xml.setProperty("SelectionLanguage", "XPath");
		var data = xml.selectNodes("//recordset/record");
		var nValue = data[0].selectSingleNode(eValue);
		document.getElementById(eID).value = nValue.firstChild.nodeValue;
	}
	else{
		var xpath = new window.XPathEvaluator;
		var data = xpath.evaluate("//recordset/record", xml, null, 7, null);
		var nValue = xpath.evaluate( eValue, data.snapshotItem(0), null, 9, null).singleNodeValue;
		document.getElementById(eID).value = nValue.firstChild.nodeValue;
	}
}


function checkEmail(email) 
{ 
 var invalid = "~`|#$%&*()+={}!\"<>?/[]:; \\"; 
 var cnt=0; 
 var result=true; 


 if (email.length<5) 
 { 
  result=false; 
 } 
 if (email.indexOf("@")==-1) 
 { 
  result=false; 
 } 
 for (var i=0;i<email.length;i++) 
 { 
  if ((invalid.indexOf(email.charAt(i))!=-1)&&(result==true)) 
  { 
   result=false; 
  } 
  if (email.charAt(i)=="@") 
   cnt++; 
 } 
 if (cnt>1) 
 { 
  result=false; 
 } 
 var s=email.charAt(0); 
 var e=email.charAt(email.length); 
 if ((s=="@") || (s==".") || (s=="-")) 
 { 
  result=false; 
 } 
 if ((e=="@") || (e==".") || (e=="-"))  
 { 
  result=false; 
 }
 return result;
} 
