function _refresh(nupdate) {

if( nupdate ) {
document.location=document.location+'&nupdate=true';
} else {
document.location=document.location;
}


}


function addEvent(obj, evType, fn)
        { 
                if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } 
                else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  } 
                else {  return false; } 
        }

function slides() {

	this.cuurent = '';
	
	this.toggle = function(id, kill) {
	
	if(this.cuurent == id && (kill == '' || kill == 'undefined' || kill == null)) {
	slides(id, '1');
	return;
	}
	
	if(kill || (this.cuurent != '' && this.cuurent != 'undefined' && this.cuurent != null) ) {	
	if( $("l_"+this.cuurent) ) {
	$("l_"+this.cuurent).style.color = '';
	$("l_"+this.cuurent).style.fontWeight = '';
	}
	new Effect.SlideUp(this.cuurent);
	}
	
	if(kill) {
	this.cuurent = '';
	} else {
	if( $("l_"+this.cuurent) ) {
	$("l_"+this.cuurent).style.color = '#f00';
	$("l_"+this.cuurent).style.fontWeight = 'bold';
	}
	new Effect.SlideDown(id);
	this.cuurent = id;
	}	   
	
}
	return this;
	}
	
function count_down(elem_id, time_left){
                v=new Date();
                var bxx=document.getElementById(elem_id);
                n=new Date();
                ss=time_left;
                s=ss-Math.round((n.getTime()-v.getTime())/1000.);
                m=0;h=0;
                if(s<0){
                  bxx.innerHTML="Zakoí¡‹í¹¯no"
                }else{
                  if(s>59){
                    m=Math.floor(s/60);
                    s=s-m*60
                  }
                  if(m>59){
                    h=Math.floor(m/60);
                    m=m-h*60
                  }
                  if(s<10){
                    s="0"+s
                  }
                  if(m<10){
                    m="0"+m
                  }
                  bxx.innerHTML=""+h+":"+m+":"+s+""
                }
                time_left=time_left-1;
                
                window.setTimeout("count_down('"+elem_id+"','"+time_left+"');",999);

              }

function addBookmark(title,url) {

  var msg_netscape = "WiadomoÂ¶äŸŽetscape";
  var msg_opera    = "Ta funkcja nie dzia3a z tÂ± wersjÂ± Opery. Dodaj nas do ulubionych ré¢ºnie.";
  var msg_other    = "Twoja przeglÂ±darka nie wspiera automatycznego dodawania do ulubionych. Dodaj nas do ulubionych ré¢ºnie.";
  var agt          = navigator.userAgent.toLowerCase();


  if (agt.indexOf("opera") != -1) 
  {
    if (window.opera && window.print)
    {
      return true;
    } else 
    {
      alert(msg_other);
    }
  }    
  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
  else alert(msg_other);
  
}


function lon(target)
{
	if (undefined == target)
		target = this;

	target.document.getElementById("loaderContainer").style.display = "";
  
	return true;
}

function loff(target)
{
	if (undefined == target)
		target = this;

	target.document.getElementById("loaderContainer").style.display = "none";
	
}


var i=0;
function blink(text) {
if(document.layers)
  document.write('<span class=normal><blink>'+text+'</blink></span>');
else {
document.write('<span class=normal id=\"s'+i+'\">'+text+'</span>');
  blink_count(i++);
}
}

function blink_count(i) {
  var s=document.getElementById("s"+i);
   with(s.style)
    visibility=(visibility=="visible")?"hidden":"visible";
   setTimeout("blink_count("+i+")",455);
}


function checkAll( n, val, _form ) {
	if(_form != '' && _form != 'undefined' && _form != null) {
	var f = eval( 'document.' + _form );
	} else {
	var f = document.adminForm;
	}
	
	if(val != '' && val != 'undefined' && val != null) {
	var val2 = 'f.' + val;
	} else {
	var val2 = 'f.cb';
	}
	
	
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( val2 + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
 } 



function xshow(o) {
	s = '';
	var _window = window.open("",'aaa',"width=680,height=600,resizable,scrollbars=yes");
	for(e in o) {
	_window.document.write(e+'='+o[e]+'<br>');
//s += e+'='+o[e]+'<br>';
	}
  //	document.write( s );
 //	alert( s );
 
}

var Calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el, 'Tl');	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}


function popupWindow(mypage, myname, w, h, scroll) {

   if(w == '' && h == '') {
	var w = screen.width * 0.8;
	var h = screen.height * 0.8; 
	}

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	
	
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function mosDHTML(options){ 
  
  this.options = {  
	onTabStyle:'ontab',
	offTabStyle: 'offtab',
	tab: 'tab',
	page: 'page'
 }	
 this.activeTab = '';
 
 Object.extend(this.options, options || {});
	
	this.setElemStyle = function(id,style) {
	if($(id)) {
		$(id).className = style;
	}
	}
	
	this.showElem = function(id) {
	if($(id)) {
			$(id).style.visibility = 'visible';
			$(id).style.display = 'block';
	}
	}
	
	this.hideElem = function(id) {
	if($(id)) {
			$(id).style.visibility = 'hidden';
			$(id).style.display = 'none';
	}
	}
	
	this.cycleTab = function(name) {
		
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.options.offTabStyle );
			page = this.activeTab.replace( this.options.tab, this.options.page );
			this.hideElem(page);
		}
		this.setElemStyle( name, this.options.onTabStyle );
		this.activeTab = name;
		page = this.activeTab.replace( this.options.tab, this.options.page );
		this.showElem(page);
	}
	return this;
}

var dhtml = new mosDHTML();




function rotateElements(tab_name, page_name){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	

	
	this.showElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {
	
		if (this.activeTab) {
			page = this.activeTab.replace( tab_name, page_name );
			this.hideElem(page);
		}
		
	  if(this.activeTab == name) {
	      page = this.activeTab.replace( tab_name, page_name );
			this.hideElem(page);
			this.activeTab = '';
	  } else {	
		this.activeTab = name;
		page = this.activeTab.replace( tab_name, page_name );
		this.showElem(page);
	  }	
	}
	return this;
}



function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}

function wt_toggleObject(objectID) {
	if(document.getElementById) {
		if(document.getElementById(objectID).className == 'pagetext') {
			wt_showObject(objectID);
		} else {
			wt_hideObject(objectID);
		}
	}
}

function wt_showObject(objectID) {
	if(document.getElementById) {
		document.getElementById(objectID).className = 'show';
	}
}

function wt_hideObject(objectID) {
	if(document.getElementById) {
		document.getElementById(objectID).className = 'pagetext';
	}
}

function wt_toggleObject2(objectID) {
	if(document.getElementById) {
		if(document.getElementById(objectID).className == 'pagetext') {
		   setCookie(objectID, '1');
			wt_showObject(objectID);
		} else {
			deleteCookie(objectID);
			wt_hideObject(objectID);
		}
	}
}
 
var paymentInfo = new rotateElements('pa_tab', 'pa_page');
var shippingInfo = new rotateElements('sh_tab', 'sh_page');

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
