//////////////////////////////////////////////////////////////////////////
///////Wysrodkowany pop up
//////////////////////////////////////////////////////////////////////////
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

//////////////////////////////////////////////////////////////////////////
///////POKAZ ALBO UKRYJ
//////////////////////////////////////////////////////////////////////////

function pokazAlboUkryj(co) {

     var obiekt = document.getElementById(co);

     if (obiekt.style.display == 'none') {
      document.getElementById('down').style.display = 'none';
      obiekt.style.display = 'block';
      document.getElementById('up').style.display = 'inline';

     } else {
          obiekt.style.display = 'none';
          document.getElementById('down').style.display = 'inline';
          document.getElementById('up').style.display = 'none';

     }

}	 

function pokazAlboUkryjI(co) {

     var obiekt = document.getElementById(co);

     if (obiekt.style.display == 'none') {
      document.getElementById('down').style.display = 'none';
      obiekt.style.display = 'inline';
      document.getElementById('up').style.display = 'inline';

     } else {
          obiekt.style.display = 'none';
          document.getElementById('down').style.display = 'inline';
          document.getElementById('up').style.display = 'none';

     }

}	
 
function pokazAlboUkryjFav(co) {

     var obiekt = document.getElementById(co);

     if (obiekt.style.display == 'none') {
      obiekt.style.display = 'block';

     } else {
          obiekt.style.display = 'none';
     }

}

//////////////////////////////////////////////////////////////////////////
///////Pobierz ciastka
//////////////////////////////////////////////////////////////////////////

function getCookie(nazwa) {
  var cookieStr = document.cookie;
  if((start = cookieStr.indexOf(nazwa + "=")) == -1 )
    return false;
  start += nazwa.length + 1;
  if((end = cookieStr.indexOf(";", start)) == -1)
    end = cookieStr.length;
  return cookieStr.substring(start, end);

}



///////////////////////////////////////////


var submitted = false;
function doSubmit() {
	if (! submitted) {
		submitted = true;
		ProgressImg = document.getElementById('progress_img');
		document.getElementById("loading").style.display = "block";
		setTimeout("ProgressImg.src = ProgressImg.src",100);
		return true;
		}
	else {
		return false;
		}
	}
	
	

//////////////////////////////////////////////

function showDiv(id) {
  var photo = document.getElementById(id);
  var div = document.getElementById("data");
  div.innerHTML = photo.clientLeft;

}

function show(id) {
  var obiekt = document.getElementById(id);
  if (obiekt.style.display == 'none') {
    obiekt.style.display = 'block';
  }

}

function hide(id) {
  var obiekt = document.getElementById(id);
  if (obiekt.style.display == 'block') {
    obiekt.style.display = 'none';
  }

}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
