function readCookie(name) {
	var namearg = name + "=";
	var nlen = namearg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + nlen;
		if (document.cookie.substring(i, j) == namearg) {
			var endpos = document.cookie.indexOf (";", j);
			if (endpos == -1) endpos = document.cookie.length;
			var f = unescape(document.cookie.substring(j, endpos));
			return unescape(document.cookie.substring(j, endpos));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return 0;
}

function deleteCookie(name) {
   if (readCookie(name)) {
     document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

function writeCookie(name, value, expiry) {
	//alert('name: ' + name + ' value: ' + value);
	var expdate = new Date();	
	if(expiry) { //horas
		expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * expiry);
		document.cookie = name + "=" + value + "; expires=" + expdate.toGMTString();
	}
	else {
		document.cookie = name + "=" + value;
	}
}

function ShowFile(ImgId, Width, Height)
{
	var w = window.open('ShowFile.aspx?ImgId=' + ImgId + '&Width=' + Width + '&Height=' + Height,'','toolbar=no,location=no,directories=no,status=no,menubar=no,width=200,height=200,resizable=no,top=100,left=100');
}

function ShowPluginsFile(Img, Width, Height)
{
	var w = window.open(Img);
}

function PrintIt(Url)
{
	var w = window.open(Url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,width=500,height=600,resizable=no,top=100,left=100,scrollbars=no');
}

function updateData (id, cols, current, record_id, edit, url) {
	try {
		window.location = url + record_id;

		var oTable = document.getElementById(id);
		var row = document.frm.rows.value;
		cols--;
		var index = 1;
		while (index <= row) {
			if ( index % 2 == 1) {
				for (var i = 0; i < cols; i++)
					oTable.rows[index].cells[i].style.background = "#FFFFFF";
				
				oTable.rows[index].style.background = "#FFFFFF";
			} else {
				for (var i = 0; i < cols; i++)
					oTable.rows[index].cells[i].style.background = "#EFEFEF";
				
				oTable.rows[index].style.background = "#EFEFEF";								
			}				
			index++;				
		}
			
		for (var i=0; i < cols; i++)
			oTable.rows[current + 1].cells[i].style.background = "#BDC7D3";
	}
	catch(e)
	{
		
	}
}	

	function SelectAllCheckboxes(spanChk){
	
	// Added as ASPX uses SPAN for checkbox 
	var xState=spanChk.checked;
	var theBox=spanChk;
	
	
		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++)
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
			{
			//elm[i].click();
			if(elm[i].checked!=xState)
			elm[i].click();
			//elm[i].checked=xState;
			}
	}

	//-------------------------------------------------------------
	//----Select highlish rows when the checkboxes are selected
	//
	// Note: The colors are hardcoded, however you can use 
	//       RegisterClientScript blocks methods to use Grid's
	//       ItemTemplates and SelectTemplates colors.
	//		 for ex: grdEmployees.ItemStyle.BackColor OR
	//				 grdEmployees.SelectedItemStyle.BackColor
	//-------------------------------------------------------------
	function HighlightRow(chkB)	{
	
	var xState=chkB.checked;
		
	if(xState)
		{chkB.parentElement.parentElement.style.backgroundColor='lightcoral';  // grdEmployees.SelectedItemStyle.BackColor
		 chkB.parentElement.parentElement.style.color='white'; // grdEmployees.SelectedItemStyle.ForeColor
		}else 
		{chkB.parentElement.parentElement.style.backgroundColor='white'; //grdEmployees.ItemStyle.BackColor
		 chkB.parentElement.parentElement.style.color='black'; //grdEmployees.ItemStyle.ForeColor
		}
	}
	// -->