var getVars = new Array();
var locvartemp = ( window.location.href.indexOf( "?" ) + 1 ) ? window.location.href.substr( window.location.href.indexOf( "?" ) + 1 ) : "";
locvartemp = locvartemp.split( "&" );
for( var x = 0; x < locvartemp.length; x++ ) {
    var lvTempVar = locvartemp[x].split( "=" );
    getVars[ unescape( lvTempVar[0] ) ] = unescape( lvTempVar[1] );
}
if(!getVars['d']) {getVars['d']='start';}
function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}

var overMenu=0;

function addParams(params, key, value)
{
	if(params!='') {params=params+'&';}
	params=params+encodeURIComponent(key)+'='+encodeURIComponent(value);
	return params;
}

function Ajax(m) {this.m=m;}

Ajax.prototype.send=function ()
{
  var oXmlHttp = zXmlHttp.createRequest();
  oXmlHttp.open("post", this.m, true);
  oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  try {oXmlHttp.onerror=function(error) {alert('network problem');}} catch(e) {}
  oXmlHttp.onreadystatechange = function () {
    if (oXmlHttp.readyState == 4)
	{
		status=oXmlHttp.status;
	    if (status == 200)
		{
		  var odp=oXmlHttp.responseText;
		  var info=odp.substr(0,2);
		  odp=odp.substr(2);
		  switch(info)
		  {
			case 'ao': {alert(odp); goToBrowse(); break;}
			case 'p': {fillForm(odp); break;}
			case 'mw': {mWindowCB(odp); break;}
			case 'uf': {uczFill(odp); break;}
			case 'ud': {location.reload(); break;}
			case 'kk': {location.reload(); break;}
			case 'kr': {komponentReplace(odp); break;}
			case 'uz': {location.reload(); break;}
			case 'mu': {location.reload(); break;}
			case 'md': {location.reload(); break;}
			case 'mc': {location.reload(); break;}
			case 'mz': {location.reload(); break;}
			case 'me': {alert(odp); break;}
			case 'wk': {
				document.getElementById('wyslijKartkeDiv').style.display='none';
				document.getElementById('wyslijKartkeLabel').style.display='block';
				document.getElementById('odKogo').value='';
				document.getElementById('doKogo').value='';
				document.getElementById('trescKartki').value='';
				if(getVars["lang"]=="pl") {mAlert('Kartka została wysłana. Dziękujemy');}
				if(getVars["lang"]=="en") {mAlert('Your card has benn sent. Thank you.');}
				break;
				}
			case 'nu': {
				if(getVars["lang"]=="pl") {mAlert('Dziękujemy. Twój adres został dodany do naszej bazy');}
				if(getVars["lang"]=="en") {mAlert('Thank you. Your address has been added to our database');}
				document.getElementById('newsletter_email').value=''; break;
				}
			case 'ou': {
			    if(getVars["lang"]=="pl") {mAlert('Twoja wiadomość została wysłana');}
				if(getVars["lang"]=="en") {mAlert('Your message has been sent');}
				document.getElementById('cfImie').value=''; document.getElementById('cfAdres').value=''; document.getElementById('cfTytul').value=''; document.getElementById('cfTresc').value=''; break;}
			default: {alert("message\n"+oXmlHttp.responseText);}
		  }
		} else {alert("An error occurred: " + oXmlHttp.statusText);}
    }             
  };
  oXmlHttp.send(this.params);
}

Ajax.prototype.addParams=function (key, value)
{
  if(this.params!='') {this.params=this.params+'&';}
  this.params=this.params+encodeURIComponent(key)+'='+encodeURIComponent(value);
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
function goToFormPage(page)
{
  window.location='/?d='+getVars['d']+'&p='+page;
}

var EventUtil=new Object;

EventUtil.getEvent=function() {
  if(window.event) {return this.formatEvent(window.event);}
  else {return EventUtil.getEvent.caller.arguments[0];}
}

function resetMenu() {}

function selectMenu(menu)
{  
 
  var menuDiv=document.getElementById('menu');
  //alert('start');
  for(i=0;i<menuDiv.childNodes.length;i++) {
    var node=menuDiv.childNodes[i];
	if( node.className=='childrens selected' ) {var selectedMenu=node;}
  }
  try {
  nextMenu=document.getElementById('div_'+menu);
  selectedMenu.className='childrens';
  selectedMenu.style.display='none';
  nextMenu.className='childrens selected';
  nextMenu.style.display='block';
  } catch(e) {}
}

function resetInput(el, p) {if(el.value==p) {el.value="";}}
function searchSubmit() {try {document.getElementById("search").submit();} catch(e) {}}

