b1= new Image(); 	b1.src="gfx/header_b12.jpg"; 
b2= new Image(); 	b2.src="gfx/header_b22.jpg"; 
b3= new Image(); 	b3.src="gfx/header_b32.jpg"; 
p1= new Image(); 	p1.src="gfx/product_box2.jpg"; 
p2= new Image(); 	p1.src="gfx/product_box2b.jpg"; 


function cat_mouse(state,id)
{
	if (state==1)
	{
		document.getElementById("cat"+id).style.cursor="pointer";
		document.getElementById("cat"+id).style.fontWeight="bold";
		document.getElementById("cat"+id).style.color="#ff0000";
		document.getElementById("arrow"+id).style.color="#ff0000";
	}
	if (state==0)
	{
		document.getElementById("arrow"+id).style.color="#aed6ea";
		document.getElementById("cat"+id).style.fontWeight="normal";
		document.getElementById("cat"+id).style.color="#31779a";
	}
}

function PopupPic(sPicURL)
{ 
	image=window.open("pub/windowPic.php?picture="+sPicURL, "image", "resizable=1,HEIGHT=200,WIDTH=200");
	if (window.focus) {image.focus()}
}


function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;

	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13){search_voy();return false}
	else return true;
}



function search_voy()
{
	if (document.getElementById("el_search").value!="") location.href="index.php?search="+document.getElementById("el_search").value;
	else alert('Please enter the keyword(s) criteria to search.')
}

function borra()
{
	if (document.getElementById('el_search').value=="Search") document.getElementById('el_search').value="";
}

function change_showall(cual,url)
{
	if (cual=="0") document.getElementById('showall_input').value="0";
	if (cual=="1") document.getElementById('showall_input').value="1";
	document.el_form.action = url;
	document.el_form.submit();
}

function resize(id, max)
{
	var elem = document.getElementById(id);
	if (elem == undefined || elem == null) return false;
	if (max == undefined) max = 125;
	if (elem.width > elem.height)
	{
		if (elem.width > max) elem.width = max;
	}
	else
	{
		if (elem.height > max) elem.height = max;
	}
//	if (elem.height<124) setTimeout("center(\""+id+"\")",120);
}

function center(id)
{
	var elem = document.getElementById(id);
	elem.style.top=(125-elem.offsetHeight)/2;
}

function ajusta()
{
	if (document.getElementById('la_imagen').offsetWidth>230) document.getElementById('la_imagen').width=230;
}

///////////// POST FUNCTIONS ////////////////
function gotopage(page,search)
{
	if (search) document.el_form.action = search;
	document.getElementById('p').value=page;
	document.el_form.submit();
}

function open_cat_main(cat)
{
	document.el_form.action = "index.php?cat_main="+cat;
	document.getElementById('url').value=document.el_form.action;
	document.getElementById('p').value="";
	document.el_form.submit();
}

function open_cat_sub(main,sub)
{
	document.el_form.action = "index.php?cat_main="+main+"&cat_sub="+sub;
	document.getElementById('prod_all').value=0;
	document.getElementById('url').value=document.el_form.action;
	document.getElementById('p').value="";
	document.el_form.submit();
}

function open_prod_all(value,main,sub,search)
{
	if (search) document.el_form.action = search;
	else document.el_form.action = "index.php?cat_main="+main+"&cat_sub="+sub;
	if (value==0) document.getElementById('prod_all').value=0;
	if (value==1) document.getElementById('prod_all').value=1;
	document.getElementById('p').value="";
	document.el_form.submit();
}

function open_prod(main,sub,prod)
{
	document.el_form.action = "index.php?cat_main="+main+"&cat_sub="+sub+"&product_id="+prod;
	document.getElementById('p').value="";
	document.el_form.submit();
}

function search_submit(search)
{
	document.el_form.action = "index.php?search="+search;
	document.el_form.submit();
}

function parche()
{
	if (document.getElementById('showall_input').value==1) document.getElementById('showall_input').value=0;
	else document.getElementById('showall_input').value=1;		
}

function home()
{
	document.el_form.action = "index.php";
	document.getElementById('url').value="";
	document.getElementById('prod_all').value="";
	document.getElementById('p').value="";
	document.el_form.submit();
}

