function comparision_add(value)
{
	//alert(value);
	if($('comparison_id_value'))
	{
		$('comparison_id_value').value=value;
		//	document.comparison_send.comparison_id_value.value='$row[id]'; 
		if($('comparison_id_value').form)	$('comparison_id_value').form.submit();
	}
}

function insertPicture(field,picture_min,picture_max,x,y)
{
	var field=document.getElementById(field);
	var frame;
	if (picture_max && x && y)
		frame=" style='cursor:pointer' onClick=\"window_open('frame.php?image=" + picture_max + "',''," + x + "," + y + ")\"";
	field.innerHTML="<img src=\"" + picture_min + "\" " + frame + " border=\"0\" >";
}

function window_open(URL, name, width, height)
{
	var left=(screen.width-width)/2;
	left=Math.round(left);
	var top=(screen.height-height-100)/2;
	top=Math.round(top);
	name=window.open(URL, name, 'resizable=0, height=' + height + ', width=' + width + ', top=' + top + ', left=' + left);
	name.moveTo(left, top);
	name.focus();
}

function window_open_resizable(URL, name, width, height)
{
	var left=(screen.width-width)/2;
	left=Math.round(left);
	var top=(screen.height-height-100)/2;
	top=Math.round(top);
	name=window.open(URL, name, 'resizable=1,scrollbars=1, height=' + height + ', width=' + width + ', top=' + top + ', left=' + left);
	name.moveTo(left, top);
	name.focus();
}


function activeTab(active)
{
	
	var content=document.getElementById("tabDescription").getElementsByTagName("div");
	var header=document.getElementById("tabs").getElementsByTagName("div");
	
	var j = 0;
	
	for (var i=1; i<=content.length; i++)
	{

		if( content[i-1].className == 'tab_div')
		{

			j++;	
	
		
		if (j==active)
		{

			content[i-1].style.display='inline';
			header[j-1].style.backgroundImage='url(image/icon/tab_on.gif)';
			header[j-1].style.cursor='default';
			
		}
		else
		{
			content[i-1].style.display='none';
			header[j-1].style.backgroundImage='url(image/icon/tab_off.gif)';
			header[j-1].style.cursor='pointer';
			
		}
		header[j-1].style.width='103px';
		header[j-1].style.height='18px';
		header[j-1].style.backgroundPosition='top';
		header[j-1].style.backgroundRepeat='no-repeat';
		header[j-1].style.paddingTop='7px';
		header[j-1].style.color='#FFFFFF';
		header[j-1].style.fontWeight='bold';
		
		//header[i-1].style.border='1px solid black';
		
			}
	}
	
}

function ShowDiv(element)
{
	var elem=document.getElementById(element);
	if (elem.style.display=='inline') elem.style.display='none'; else elem.style.display='inline';
}

function ActiveDeactiveDiv(element,show)
{
	var elem=document.getElementById(element);
	if (show=='0') elem.style.display='none'; else elem.style.display='inline';
}
function ShowHideElement(element,style_display_on)
{
	var elem=document.getElementById(element);
	if (elem.style.display=='none') 
		elem.style.display=style_display_on; 
	else 
		elem.style.display='none';
}


function insertVaulue(value,field)
{
		var field=document.getElementById(field);
		
		field.value=value;
}

// uzywana w skroceniu tekstu
// przy komentarzu klienta do zamowienia
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.innerHTML = limitNum - limitField.value.length;
	}
}
/**----------------------------------------------------------
	obsluga menu
*/
	var cookieTime=0;
/**----------------------------------------------------------
*/
	function createCookie(name,value,days) 
	{
		if (days) 
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
/**----------------------------------------------------------
*/
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
/**----------------------------------------------------------
*/
	function eraseCookie(name) 
	{
		createCookie(name,"",-1);
	}
/**----------------------------------------------------------
*/
	function createMenuCookie(submenuId)
	{
		cookieName='menu['+submenuId+']';
		createCookie(cookieName,1,cookieTime);	
	}
/**----------------------------------------------------------
*/
	function eraseMenuCookie(submenuId)
	{
		cookieName='menu['+submenuId+']';
		eraseCookie(cookieName);	
	}
/**----------------------------------------------------------
*/
	function menuClick(submenuId,mode,elem)
	{		
		//alert(submenuId+' '+mode+' '+elem);
		if($(submenuId))
		{	
			if(Element.visible($(submenuId))) 
			{
				Element.hide($(submenuId));
				eraseMenuCookie(submenuId);
				/*$(submenuId+'_nav').src="./image/template/menu_show_down.gif";*/
				Element.show($(submenuId+'_nav_down'));
				Element.hide($(submenuId+'_nav_up'));
				//$(elem).innerHTML='+';
			}
			else 
			{
				if(mode==1) hide_all('menuRoot','submenu');
				Element.show($(submenuId));
				createMenuCookie(submenuId);
				/*$(submenuId+'_nav').src="./image/template/menu_show_up.gif";*/
				Element.show($(submenuId+'_nav_up'));
				Element.hide($(submenuId+'_nav_down'));
				//$(elem).innerHTML='-';
			}			
			return false;
		}
		else 
		{
			alert('click');
			return true;
		}
	}
/**----------------------------------------------------------
*/
	function show_all(parentElement,className)
	{
		nodes=document.getElementsByClassName(className , $(parentElement));
		for(i=0; i<nodes.length; i++)
		{
			Element.show(nodes[i]);
			submenuId=nodes[i].getAttribute('id');
			createMenuCookie(submenuId);	
			/*$(submenuId+'_nav').src="./image/template/menu_show_up.gif";*/
			Element.show($(submenuId+'_nav_up'));
			Element.hide($(submenuId+'_nav_down'));
		}
		return false;
	}
/**----------------------------------------------------------
*/
	function hide_all(parentElement,className)
	{
		nodes=document.getElementsByClassName(className , $(parentElement));
		for(i=0; i<nodes.length; i++)
		{
			Element.hide(nodes[i]);
			submenuId=nodes[i].getAttribute('id');
			eraseMenuCookie(submenuId);	
			Element.show($(submenuId+'_nav_down'));
			Element.hide($(submenuId+'_nav_up'));
		}
		return false;
	}
