var ie4 = false;
if(document.all)
{
	ie4 = true;
}

function getObject(id)
{
	if (ie4)
	{
		return document.all[id];
	}
	else
	{
		return document.getElementById(id);
	}
}

function toggle(link, divId)
{
	var lText = link.innerHTML;
	var d = getObject(divId);
	if (lText == 'edycja')
	{
		link.innerHTML = 'zwin'; d.style.display = 'block';
	}
 	else
 	{
 		link.innerHTML = 'edycja'; d.style.display = 'none';
 	}
}

function editit(URL,NAME) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, NAME, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 550,top = 300');");
}


function CheckAddToCart(CartOptions)
{
	var theone;
	for (i=0;i<CartOptions.mid.length;i++)
	{
		if (CartOptions.mid[i].checked==true)
		{
			theone=i;
		}
	}

	if(theone==undefined)
	{
		poprawny=false;
		alert("Proszę wybierz opcję produktu");
	}
	else
	{
		poprawny=true;
		alert("Produkt został dodany do koszyka");
	}
	
	return poprawny;
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function searchutility() {
    
    s=document.search.q.value.toLowerCase();
    s=s.replace(/[_;+=]/gi,' ');
    s=s.replace(' -','-');
    s=s.replace('- ','-');
    //s=s.replace('-',' ');
    s=s.replace('  ',' ');
    s=s.replace(', ',',');
    s=s.replace('/',' ');
    s=s.replace('\\',' ');
    s=s.replace('\\',' ');
    s=s.replace('\'',' ');
    
    
    document.search.q.value=s.replace(' ,',',');
}



function open_win(what_link)
{
	var the_url = "PK4qrX26sNL"
	var the_x = 620;
	var the_y = 620;
	the_x -= 0;
	the_y -= 0;
	var how_wide = screen.availWidth;
	var how_high = screen.availHeight;
	if(what_link != ""){the_url=what_link;}
	var the_toolbar = "no";
	var the_addressbar = "no";
	var the_directories = "no";
	var the_statusbar = "no";
	var the_menubar = "no";
	var the_scrollbars = "no";
	var the_do_resize =  "no";
	var the_copy_history = "no";
	top_pos = (how_high/2) -  (the_y/2);
	left_pos = (how_wide/2) -  (the_x/2);
	if (window.outerWidth ){
	var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
	site=open(the_url, "DisplayWindow", option);
	var Opera = (navigator.userAgent.indexOf('Opera') != -1);
	if(Opera)
	{
		site.resizeTo(the_x,the_y);
		site.moveTo(0,0);
	}
}
else
	{
	var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
	site=open('', "DisplayWindow", option);
	site.location=the_url;
	if(site.open){site.focus();return false;}
	site.resizeTo(the_x,the_y);
	}
}