function borrametio(name){
	if(document.getElementById(name).value == name){
		document.getElementById(name).value = '';
	}
}
function llenametio(name){
	if(document.getElementById(name).value == ''){
		document.getElementById(name).value = name;
	}
}
function NuevoAjax(){var xmlhttp=false;try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp = false;}
}
if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function llamarasincrono(url, id){
	$.get(url,function(d){$('#'+id).html(d);});
}
function checkselected(ctrl) {
	for(i=0;i<ctrl.length;i++)
		if(ctrl[i].checked) return ctrl[i].value;
}
function search_next(file){
	var selected = checkselected(document.search_form.find);
	var search_input = document.getElementById('search_input').value;
	llamarasincrono(file+"?s="+selected+"&f="+encodeURIComponent(search_input), "return_box");
}
var lineCount = new Array();
function addFormLine(div, line, f)
{
	var f = (f == null) ? "" : f;
	lineCount[div] = lineCount[div] == null ? 1 : lineCount[div] + 1;
	var mySelf = div + "_line_" + lineCount[div];
	var myNum = lineCount[div];
	var divTarget = document.getElementById(div);
	var divLine = document.getElementById(line).innerHTML;
	var divTitle = document.getElementById(line).getAttribute('title');
	var newDiv = document.createElement('div');
	newDiv.className = 'row';
	newDiv.setAttribute('id', mySelf);
	divLine = divLine.replace(/mySelf/g, mySelf);
	newDiv.innerHTML = divLine;
	newDiv.innerHTML += "<div class=\"cell\"><img style=\"cursor: pointer;\" src=\"../images/cancel.png\" border=\"0\" onclick=\"removeFormLine(\'" + mySelf + "\'); " + f + "\"></div>";

	divTarget.appendChild(newDiv);
}
function removeFormLine(div)
{
	var parentName = div.replace(/_line_\w+/g, '');
	var divParent = document.getElementById(parentName);
	var divTarget = document.getElementById(div);
	var hasTitle = divParent.getAttribute('cab');
	divParent.removeChild(divTarget);
	if (hasTitle != null && divParent.childNodes.length == 1){
		divParent.innerHTML = "";
	}
}

function rcart(){
	$("#rcart button").attr("disabled",1);
	$.ajax({
		type: "POST",
		url: self.location.href,
		data: $('#rcart form').serialize(),
		success: function(d){
			$("#rcart button").removeAttr("disabled");
			alert('Mensaje Enviado, Gracias!');
		}
	});
}

