function insertPicture(field,picture_min,picture_max,x,y)
{
	doInsertPicture(field,picture_min,picture_max,x,y,'');
}


function doInsertPicture(field,picture_min,picture_max,x,y, alt)
{		
	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 + " style=\"border:none; margin: auto;\" alt=\""+alt+"\" />";
}

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();
}


// active - indeks zakladki
function activeTab(active)
{

	var content=document.getElementById("tabDescription").getElementsByTagName("div");
	var header=document.getElementById("tabs").getElementsByTagName("div");


	var arr_content = new Array();
	var k=0;
	// wybieramy wszystkie divy z klasa tab_div
	for (var i=0; i<content.length; i++)
	{
		if( content[i].className == 'tab_div')
		{
			arr_content[k++] = content[i];
		}
	}

	var arr_header = new Array();
	k=0;
	// wybieramy wszystkie divy z klasa tab_div
	for (var i=0; i<header.length; i++)
	{
		if( header[i].className == 'tab_div')
		{
			arr_header[k++] = header[i];
		}

	}

	for (var i=0; i<arr_header.length; i++)
	{
		if (i==active)
		{

			arr_content[i].style.display='inline';
			arr_header[i].style.backgroundImage='url(image/icon/tab_on.gif)';
			arr_header[i].style.cursor='default';
		}
		else
		{
			arr_content[i].style.display='none';
			arr_header[i].style.backgroundImage='url(image/icon/tab_off.gif)';
			arr_header[i].style.cursor='pointer';
		}
		arr_header[i].style.color='#FFFFFF';
		arr_header[i].style.width='118px';
		arr_header[i].style.height='26px';
		arr_header[i].style.backgroundPosition='top';
		arr_header[i].style.backgroundRepeat='no-repeat';
	}
}

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;
	}
}

/**----------------------------------------------------------
*/
	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);
	}

/* przyciski widoku zdjec na karcie towaru */
function change_offer_image_button(element)
{
	var new_b = element;
	var contener = $('offer_view_image_active_button');
	if (new_b.id!=contener.value)
	{
		var old_b = $(contener.value);
		new_b.className = 'button_item active zoom_selected';
		old_b.className = 'button_item zoom';
		contener.value = new_b.id;
	}
}

