// JavaScript Document
function growTextarea(textarea)	
	{
	// Opera isn't just broken. It's really twisted.
	if (textarea.scrollHeight > textarea.clientHeight && !window.opera)
		{
		while(textarea.scrollHeight > textarea.clientHeight)
			{
			textarea.rows += 1;
			}
		}
	}

function cart()
{
	if ((document.getElementById('listCar').style.display)!='none')
	{
		$('#listCar').fadeOut('slow');
		$('#shop').fadeOut('slow');
		$('#btnExplode').show();
		$('#btnImplode').hide();
		$.ajax({
		   type: "POST",
		   url: "/explodeImplode.php",
		   data: "uid=1&"})

	} 
	else
	{
		$('#listCar').fadeIn('slow');
		$('#shop').fadeIn('slow');
		$('#btnExplode').hide();
		$('#btnImplode').show();
	    $.ajax({
		   type: "POST",
		   url: "/explodeImplode.php",
		   data: "uid=0&"})
	}
	return false;
}
function removeShop(e)
{
   divx =document.getElementById("listCart2");
   $.ajax({
   type: "POST",
   url: "/addShop.php",
   data: "uid="+e+"&type=remove&",
   datatype:"html",
   success: function(html){
      divx.innerHTML=html;
   },
   complete: function(){

	
		  divy = document.getElementById("expCount");
		  divz = document.getElementById("impCount");

			$.ajax({
			   type: "POST",
			   url: "/countCatalog.php",
			   success: function(html){
				divy.innerHTML=html;
				divz.innerHTML=html;
				if (html==0)
						{
							$('#shop').fadeOut('slow');
							$('#listCar').fadeOut('slow');
							$('#btnImplode').hide();
							$('#btnExplode').show();
							scroll(0,0);
						}
						else
						{
								$('#listCar').fadeIn('slow');
								$('#shop').fadeIn('slow');		
								$('#btnExplode').hide();
								$('#btnImplode').show();
								scroll(0,0);
						}
				}});
	
   }
 });
	$.ajax({
	   type: "POST",
	   url: "/explodeImplode.php",
	   data: "uid=0&"})
}

function removeShopTotal(e)
{
	divx =document.getElementById("listCart2");
  $.ajax({
   type: "POST",
   url: "/addShop.php",
   data: "uid="+e+"&type=removeTotal&",
   datatype:"html",
   success: function(html){
      divx.innerHTML=html;
   },
   complete: function(){

	
		  divy = document.getElementById("expCount");
		  divz = document.getElementById("impCount");

			$.ajax({
			   type: "POST",
			   url: "/countCatalog.php",
			   success: function(html){
				divy.innerHTML=html;
				divz.innerHTML=html;
				if (html==0)
						{
							$('#shop').fadeOut('slow');
							$('#listCar').fadeOut('slow');
							$('#btnImplode').hide();
							$('#btnExplode').show();
							scroll(0,0);
						}
						else
						{
								$('#listCar').fadeIn('slow');
								$('#shop').fadeIn('slow');		
								$('#btnExplode').hide();
								$('#btnImplode').show();
								scroll(0,0);
						}
				}});
   }
 });
	$.ajax({
	   type: "POST",
	   url: "/explodeImplode.php",
	   data: "uid=0&"})
	
	$('#box'+e).fadeOut('slow');
	$('#UNO'+e).fadeOut('slow');
/*	var txt = 'Está seguro de eliminar el registro?<br><input type="hidden" id="list" name="list" value="'+ e +'" />';
	$.prompt(txt,{
		show:'fadeIn' ,
		opacity:0,
		buttons:{Eliminar:true, Cancelar:false},
		callback: function(v,m){
										   
			if(v){
				var ex = m.find('#IMP').val();
				  $('#IMP'+ex).fadeOut(500, function(){ $(this).remove(); });
					});
		 		}
			else{}
		}
	});*/
}

function shipping(e)
{
	pais = document.getElementById('cSet').value;
	pedido = document.getElementById('totalPedido').value;
	ship = document.getElementById('ship').value;
	totCantidad = document.getElementById('totQuantity').value;
	if (ship=='true') 
	{
		calculate(e,pedido, pais,totCantidad);
		document.getElementById('ship').value='false';
	}
	else 
	{
		calculate(e,pedido, 'XX',0);
		document.getElementById('ship').value='true';
	}
}

function viewMore(a,b)
{
	 $("#"+a).hide();
	 $("#"+b).show();
	 //$("#"+b).slideToggle("slow");
	 return false;
}


function doblePass()
{
	 pass2=document.getElementById('password2').value;
	 pass3=document.getElementById('password3').value;
	 if (pass2==pass3) 
	 {
	//	 var formulario=document.getElementById('frmNewPass');
		 //document.frmNewPass.submit;
	//	 formulario.submit();
	return true;
	 }
	 else
	 {
	 document.getElementById('password2').className="inputError"
	 document.getElementById('password3').className="inputError"
	 $('#MessagePass').show();
	 return false;
	 }
}

function doblePass2()
{
	 document.getElementById('password2').className="input2"
}
function doblePass2()
{
	 document.getElementById('password3').className="input2"
}
function toggleMore(a,b)
{
	 $("#"+b).hide();
	 $("#"+a).show();
	 //$("#"+a).slideToggle("slow");
	 return false;
}

function shipping1(e)
{
	pais = document.getElementById('cSet1').value;
	pedido = document.getElementById('totalPedido1').value;
	calculate1(e,pedido, pais);
}
function shipping2(e)
{
	pais = document.getElementById('cSet2').value;
	pedido = document.getElementById('totalPedido2').value;
	calculate2(e,pedido, pais);
}
// execute your scripts when DOM is ready. this is a good habit
function scrollingD()
{
$(function() {		
$("div.scrollable").scrollable();
});
}
function filtrohistorico(e)
{
	pos = document.getElementById('orderbyq').value;
	asc = document.getElementById('orderbyq1').value;
	
	if (e=='cant')
	{	
		if (pos=='0' && asc=='a')
		{
		document.getElementById('orderbyq').value='1';
		document.getElementById('orderbyq1').value='a';
		}
		else
		{
			if (asc=='a')
			{
			document.getElementById('orderbyq').value='4';
			document.getElementById('orderbyq1').value='d';
			}
			else
			{
			document.getElementById('orderbyq').value='1';
			document.getElementById('orderbyq1').value='a';
			}
		}
	}
	
	if (e=='fech')
	{	
		if (asc=='a')
			{
			document.getElementById('orderbyq').value='7';
			document.getElementById('orderbyq1').value='d';
			}
		else
			{
			document.getElementById('orderbyq').value='0';
			document.getElementById('orderbyq1').value='a';
			}
	}
	if (e=='item')
	{	
		if (pos=='0' && asc=='a')
		{
		document.getElementById('orderbyq').value='3';
		document.getElementById('orderbyq1').value='a';
		}
		else
		{
			if (asc=='a')
			{
			document.getElementById('orderbyq').value='6';
			document.getElementById('orderbyq1').value='d';
			}
			else
			{
			document.getElementById('orderbyq').value='3';
			document.getElementById('orderbyq1').value='a';
			}
		}
	}
	if (e=='cost')
	{	
		if (pos=='0' && asc=='a')
		{
		document.getElementById('orderbyq').value='2';
		document.getElementById('orderbyq1').value='a';
		}
		else
		{
			if (asc=='a')
			{
			document.getElementById('orderbyq').value='5';
			document.getElementById('orderbyq1').value='d';
			}
			else
			{
			document.getElementById('orderbyq').value='2';
			document.getElementById('orderbyq1').value='a';
			}
		}
	}
document.frmNews.submit();
}

function showFactura(e)
{
	if ((document.getElementById(e).style.display)!='none')
	{
		$('#'+e).fadeOut('slow');
	} 
	else
	{
		$('#'+e).fadeIn('slow');
	}
	return false;
}
function goesTo(e)
{
window.location=e.value; 
}
function editMail()
{
		$('#showEditMail2').show();
		$('#showEditMail').hide();
	return false;
}
function closeMail()
{
		$('#showEditMail').show();
		$('#showEditMail2').hide();
	return false;
}