// JavaScript Document
//function for show or hide data
function showHideStatus(sId,anchorImgId,sImagePath)
{
	
	oObj = eval(document.getElementById(sId));
	if(oObj.style.display == 'block')
	{
		oObj.style.display = 'none';
		eval(document.getElementById(anchorImgId)).src =  'themes/images/inactivate.gif';
		eval(document.getElementById(anchorImgId)).alt = 'Display';
		eval(document.getElementById(anchorImgId)).title = 'Display';
	}
	else
	{
		oObj.style.display = 'block';
		eval(document.getElementById(anchorImgId)).src = 'themes/images/activate.gif';
		eval(document.getElementById(anchorImgId)).alt = 'Hide';
		eval(document.getElementById(anchorImgId)).title = 'Hide';
	}
}

//function for dynmaic row

function addRow(tableID) 
{
	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rowCount;
	var colCount = table.rows[0].cells.length;
		for(var i=0; i<colCount; i++) {	 
            
			var newcell = row.insertCell(i);
			newcell.className='tabledata';
           			// newcell.style.background='#ffffff';
			
			   newcell.innerHTML = table.rows[0].cells[i].innerHTML;
			 

				//alert(newcell.childNodes[0].type);
				switch(newcell.childNodes[0].type) {

				case "text":
					newcell.childNodes[0].value = "";
					var nod_id = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
					
				break;

				case "hidden":

					newcell.childNodes[0].value = "";

					var nod_id_hidden = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;

				break;

				case "button":

					var nod_id = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;

				break;

				case "checkbox":

				newcell.childNodes[0].checked = false;
				var nod_id_chk = newcell.childNodes[0].id;
				newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
				

				break;

				case "select-one":
				
				newcell.childNodes[0].selectedIndex = 0;
				var nod_id = newcell.childNodes[0].id;
				newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
				break;	

			}
			
			

		}
		//document.getElementById(countid).innerHTML=rowCount;

	}
	
	
	function addRow2_for_quotqations(tableID) 
{
	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var rowCount = table.rows.length;
	if(document.getElementById("hiditemcount").value=='')
	r =rowCount+1;
	else
	{
	var t=document.getElementById("edit_cnt").value;
	var t1=document.getElementById("hiditemcount").value;
	r=parseInt(t1)+parseInt(t)+1;
	}
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=r;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {		
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	//alert(newcell.childNodes[0].type);
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;		
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	//document.getElementById("stock_perunit_"+rowCount).value='1';
}
	

	
	function deleteRow(tableID) 
	{
		
		try 
		{
			var table = document.getElementById(tableID);
			//alert(table);
			var rowCount = table.rows.length;
			
			for(var i=0; i<rowCount; i++) 
				{
					var row = table.rows[i];
					
					var chkbox = row.cells[0].childNodes[0];
				  
					if(null != chkbox && true == chkbox.checked) 
					{
						if(rowCount <= 1) 
						{
							alert("Cannot delete all the rows.");
							break;
						}
						
					table.deleteRow(i);
					rowCount--;
					i--;
					}
				}

		}
		catch(e) 
		{
			alert(e);
		}

	}
	
	function deleteRow1(tableID) {

	try {

	var table = document.getElementById(tableID);

	var rowCount = table.rows.length;	

	for(var i=0; i<1; i++) {

	var row = table.rows[i];
	if(rowCount==1){
		alert('Cannot delete all the rows.');
		break;
	}
	table.deleteRow(i);
	rowCount--;
	}

	}catch(e) {

	alert(e);

	}

	}
	
	function addRow1(tableID) 
{

	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var rowCount = table.rows.length;
	if(document.getElementById("hiditemcount").value=='')
	r =rowCount+1;
	else
	{
	var t=document.getElementById("edit_cnt").value;
	var t1=document.getElementById("hiditemcount").value;
	r=parseInt(t1)+parseInt(t)+1;
	}
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=r;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {		
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	//alert(newcell.childNodes[0].type);
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;		
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	//document.getElementById("stock_perunit_"+rowCount).value='1';
}

function addRow2(tableID) 
{
	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var rowCount = table.rows.length;
	if(document.getElementById("hiditemcount1").value=='')
	r =rowCount+1;
	else
	{
	var t=document.getElementById("edit_cnt").value;
	var t1=document.getElementById("hiditemcount1").value;
	r=parseInt(t1)+parseInt(t)+1;
	}
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount1").value=r;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {		
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	//alert(newcell.childNodes[0].type);
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;		
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+r;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+r;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	//document.getElementById("stock_perunit_"+rowCount).value='1';
}
	