function addbasket(pid,id,url)
{
	var t_q = "quantity"+id;
	var quantity = eval('document.content_product.'+t_q+'.value');
	if(quantity)
	{
		var articletype_id = id;
		var product_id = pid;
		var target = url+"basket.php?action=add&pid="+product_id+"&id="+articletype_id+"&q="+quantity;
  		window.location.href = target;
	}
}

function request_offer(pid,id,url)
{
	var t_q = "quantity"+id;
	var quantity = eval('document.content_product.'+t_q+'.value');
	if(quantity)
	{
		var articletype_id = id;
		var product_id = pid;
		var target = url+"basket.php?action=enq&pid="+product_id+"&id="+articletype_id+"&q="+quantity;
  		window.location.href = target;
	}
}

function check_delivery_time(aid,url)
{
	var t_q = "quantity"+aid;
	var quantity = 1;
	var quantity = eval('document.content_product.'+t_q+'.value');
	
	F1= window.open(url+"check_delivery_time.php?aid="+aid+"&q="+quantity,"Fenster1","scrollbars=yes,width=400,height=300,left="+((screen.width-400)/2)+",top="+((screen.height-500)/2)+"')");
	F1.focus();
}

function resistance_calculator()
{	
	F1= window.open("lexicon_resistance_calculator.php","Fenster1","scrollbars=yes,width=600,height=300,left="+((screen.width-400)/2)+",top="+((screen.height-500)/2)+"')");
	F1.focus();
}

function wire_resistance_calculator()
{	
	F1= window.open("lexicon_wire_resistance_calculator.php","Fenster1","scrollbars=yes,width=600,height=300,left="+((screen.width-400)/2)+",top="+((screen.height-500)/2)+"')");
	F1.focus();
}

function openhelp(target) {
var target = target;
F1= window.open(target,"Fenster1","width=600,height=600,screenX=0,screenY=0,scrollbars=Yes,resizable=yes");
}

function treeview(a)
{
	var a = a;
	if(a!='')
	{
		for($i=0;$i<a.length;$i++)
		toggleNode(a[$i]);
	}	
}

function save_basket()
{
	F2= window.open("save_basket.php","Fenster2","scrollbars=yes,width=400,height=500,left="+((screen.width-400)/2)+",top="+((screen.height-500)/2)+"')");
	F2.focus();
}

function open_basket()
{
	window.location.replace('basket.php?stat=n');
	F2= window.open("open_basket.php","Fenster2","scrollbars=yes,width=400,height=500,left="+((screen.width-400)/2)+",top="+((screen.height-500)/2)+"')");
	F2.focus();
}

function opencondi(target)
{
	var target = target;
	F1= window.open(target,"Fenster1","width=600,height=600,screenX=0,screenY=0,scrollbars=Yes,resizable=yes");
}

function reloadheader()
{
	opener.location.reload();
	window.close();
}

function reloadmain(url, master,action)
{
	var fenster = null;

	if (opener != null)
	{
		if(!opener.closed)
		{
			if (master == '' || master == null)
			{
				fenster = opener;
			}
			else
			{
				fenster = eval("opener."+master);
			}
		}
	}
	if (fenster == null)
	{
		fenster = window.open("", "www.fuehlersysteme.de");
	}
	if (fenster != null)
	{
		fenster.location.href = url;
		fenster.focus();
		if (action != true) {
			window.top.close();
		}
	}
}

function window_basket_service()
{
	F2 = window.open("basket_service.php","Fenster2","scrollbars=no,width=450,height=500,left="+((screen.width-650)/2)+",top=0");
	F2.blur();
}

function check_taxable()
{
	s=document.form1.cbinvoiceland;
	country_id=s.options[s.selectedIndex].value;
	strArr=country_id.split("#");  

	if(strArr[0]!='2' && strArr[1]=='1')
	{
		document.getElementById("taxable").style.visibility="visible";
		document.getElementById("taxable").style.display="block";
	}
	else
	{
		document.getElementById("taxable").style.visibility="hidden";
		document.getElementById("taxable").style.display="none";
	}
}

function check_taxable_reg()
{
	s=document.create_account.cbland; 
	country_id=s.options[s.selectedIndex].value;
	strArr=country_id.split("#");  

	if(strArr[0]!='2' && strArr[1]=='1')
	{
		document.getElementById("taxable").style.visibility="visible";
		document.getElementById("taxable").style.display="block";
	}
	else
	{
		document.getElementById("taxable").style.visibility="hidden";
		document.getElementById("taxable").style.display="none";
	}
}

function textareaCounter(field,countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0,maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function handleClick(alt_id,id)
{
	if(id)
	{
		if(document.getElementById(''+id+'').style.visibility != "hidden")
		{
			document.getElementById(''+id+'').style.visibility = "hidden";
			document.getElementById(''+id+'').style.display = "none";
		}
		else
		{
			document.getElementById(''+id+'').style.visibility = "visible";
			document.getElementById(''+id+'').style.display = "block";
		}
	}
	else if(alt_id)
	{
		var arr_id = alt_id.split("#");

		for(i=0;i<arr_id.length;i++)
		{
			document.getElementById(''+arr_id[i]+'').style.visibility = "hidden";
			document.getElementById(''+arr_id[i]+'').style.display = "none";
		}
	}
}
