/*###########################################Function to Check All Checkboxes##########################*/
checked = false;
function CheckAll(str){
	var frm=eval('document.'+str);
	var count = frm.elements.length;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 0){
				frm.elements[i].checked = 1;
				frm.ch.checked=1;
			} else {
				frm.elements[i].checked = 0;
				frm.ch.checked=0;
			}
		}
	}
}
/*###########################################Function to Check Checked Checkboxes##########################*/
function chkdelete(val , val1){
	
	var count,c;
	var str=eval('document.'+val1);
	
	count=eval('document.'+val1+'.elements.length');
	c=0;
	for (i=0; i < count; i++){
		if(str.elements[i].name == 'compList[]'){
			if(str.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(c == 0){
		alert(''+val);
		return false;
	}
}
function checkFrmInqry() {
	var enqFrm=document.frmInquiry;
	if(chktrim(enqFrm.vName.value).length <=0) {
		alert("Please input your name...");
		enqFrm.vName.focus();
        return false;
	}
	if(chktrim(enqFrm.vEmail.value).length <= 0) {
		alert("Input email address...");
	    enqFrm.vEmail.focus();
	    return false;
	}
	if(!checkEmail(enqFrm.vEmail.value)) {
		alert("Input valid email address...");
		enqFrm.vEmail.value="";
		enqFrm.vEmail.focus();
		return false;
	}
	if(enqFrm.vEmail.value.indexOf('@') != enqFrm.vEmail.value.lastIndexOf('@')) {
		alert("Pleaes input only one e-mail address...");
		enqFrm.vEmail.value="";
		enqFrm.vEmail.focus();
		return false;
	}
	if(chktrim(enqFrm.vPhone.value).length <=0) {
		alert("Please input your phone number...");
		enqFrm.vPhone.focus();
        return false;
	}
	if(chktrim(enqFrm.word.value).length <=0) {
		alert("Please input Security Code...");
		enqFrm.word.focus();
        return false;
	}
	if(chktrim(enqFrm.vRequirement.value).length <=0) {
		alert("Please enter your specific requirement details...");
		enqFrm.vRequirement.focus();
        return false;
	}
	
}
function openwin1(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function chktrim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   } 
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { 
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; 
}
function checkEmail(value) {
	valids = '@.'
	temp = 0;
	for(var i = 0; i < value.length; i++) {
		if (valids.indexOf(value.substr(i,1)) != -1) {
			temp++;
		}
	}
	if(temp >= 2)
		return true
	else
		return false;
}