// JavaScript Document
function addRowToTable()
{
  var tbl = document.getElementById('tblSample');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow + 1 ;
  var row = tbl.insertRow(lastRow);

  
   
 
 // left cell
  var cellRightSel = row.insertCell(0);
  var el = document.createElement('input');
  el.type = 'text';
  el.id = 'qua' + iteration;
  el.name = 'qua' + iteration;
  el.size = 10;
  cellRightSel.appendChild(el);
 
 
 
 // middle cell
  var  cellRight = row.insertCell(1);
  var em = document.createElement('input');
  em.type = 'text';
  em.id = 'cod' + iteration;
  em.name = 'cod' + iteration;
  em.size = 70;
  cellRight.appendChild(em);

  document.getElementById('reqcount').value = parseInt(document.getElementById('reqcount').value) + 1;
  
 
 // right cell
  var cellLeft = row.insertCell(2);
  var textNode = document.createTextNode(iteration);
  cellLeft.appendChild(textNode);
}

function checkFrm() {
	if (document.getElementById('name').value == '') { 
		alert('نام و نام خانوادگی درج نشده است');
		document.getElementById('name').focus();
		return false;
	}

	if (document.frmMain.id_ostan.selectedIndex==0)
	 {
    	alert(" استان انتخاب نشده است");
	    document.frmMain.id_ostan.focus();
		return (false);
	 }
	 
	if (document.frmMain.id_shahr.selectedIndex==0)
	 {
		alert(" شهر انتخاب نشده است");
	    document.frmMain.id_shahr.focus();
		return (false);
	 }
 
 	if (document.frmMain.address.value=='')
	 {
		alert(" آدرس وارد نشده است");
	    document.frmMain.address.focus();
		return (false);
	 }

 	if (document.frmMain.postalcode.value=='')
	 {
		alert(" کد پستی وارد نشده است");
	    document.frmMain.postalcode.focus();
		return (false);
	 }

 	if (document.frmMain.hometel.value=='' & document.frmMain.mobile.value=='' & document.frmMain.worktel.value=='' )
	 {
		alert(" حداقل یک شماره تماس اجباری است");
	    document.frmMain.mobile.focus();
		return (false);
	 }


	return true;
}

function checkFrmMojadad() {

	if (document.getElementById('name').value == '') { 
		alert('نام و نام خانوادگی درج نشده است');
		document.getElementById('name').focus();
		return false;
	}

	if (document.frmMain.id_ostan.selectedIndex==0)
	 {
    	alert(" استان انتخاب نشده است");
	    document.frmMain.id_ostan.focus();
		return (false);
	 }
	 
	if (document.frmMain.id_shahr.selectedIndex==0)
	 {
		alert(" شهر انتخاب نشده است");
	    document.frmMain.id_shahr.focus();
		return (false);
	 }
 
 	if (document.frmMain.address.value=='')
	 {
		alert(" آدرس پستی درج نشده است");
	    document.frmMain.address.focus();
		return (false);
	 }

 	if (document.frmMain.postalcode.value=='')
	 {
		alert(" کد پستی درج نشده است");
	    document.frmMain.postalcode.focus();
		return (false);
	 }

 	if (document.frmMain.hometel.value=='' & document.frmMain.mobile.value=='' & document.frmMain.worktel.value=='' )
	 {
		alert(" درج حداقل یک شماره تماس الزامی است");
	    document.frmMain.mobile.focus();
		return (false);
	 }


	return true;
}