
var newWindow = null
function makeNewWindow(name,width,height) {
  var rozmery = null

rozmery = "HEIGHT=" + height + ",WIDTH=" + width
  //if (text==undefined) text = ""
 // store new window object in global variable
 newWindow = window.open("","","scrollbars=no,"+rozmery)
 if (newWindow != null) {
  // assemble content for new window
  var newContent = "<HTML><HEAD><TITLE>kliknutim na obrazek okno zavrete</TITLE></HEAD>"
  newContent += "<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 BGCOLOR='#C0C0CC'>"
  newContent += "<IMG SRC=" + name + " BORDER=0 ALIGN='CENTER' TITLE='Kliknutim na obrazek okno zavrete' VSPACE=0 onclick='self.close()'>"


  newContent += "</BODY></HTML>"
  // write HTML to new window document
  newWindow.document.write(newContent)
  newWindow.document.close()
 }
}

function openWindow(url,width,height)
{ window.open(url,"","toolbar=yes,scrollbars=no,location=no,status=no,width="+width+",height="+height+",resizable=0");
};

function ImageLauncher(url) {
  window.open(url,"","toolbar=no,scrollbars=no,location=no,status=no,width=480,height=500,resizable=0");
}

function ImageLauncher1(url) {
  window.open(url,"","toolbar=yes,scrollbars=no,location=no,status=no,width=320,height=550,resizable=0");
}

function showPic(picID, itemID){
		var popupURL = "http://localhost/blesitrh/img.php?picID=" + picID + "&itemID=" + itemID;
		window.open(popupURL, "pejskar", 'toolbar=0,location=0,directories=0,status=0,menubar=0,width=500,height=600,scrollbars=yes,resizable=yes');
}

function messageText(value) {
  if (value==1) {
    document.getElementById('predmet').value = 'Zrušení účtu';
    document.getElementById('text').value = 'Dobrý den,\n\nna základě ... Vám byl zrušen přístup k Vašemu účtu na serveru www.blesitrh.cz.\n\nNa tuto zprávu prosím neodpovídejte.\n\nAdminstrator Blesitrh.cz';

  }
  if (value==2) {
    document.getElementById('predmet').value = 'Smazání inzerátu';
    document.getElementById('text').value = 'Dobrý den,\n\nVáš inzerát v inzerci na serveru Blesitrh.cz byl z důvodu ... smazán.\n\nNa tuto zprávu prosím neodpovídejte.\n\nAdminstrator Blesitrh.cz';
  }
  if (value==3) {
    document.getElementById('predmet').value = '';
    document.getElementById('text').value = '';
  }
}


var loginFrameStatus = '';

function showLoginFrame() {
  if (loginFrameStatus == '') {
    loginFrameStatus = 'none';
  } else {
    loginFrameStatus = '';
  }
  document.getElementById('login-form-header').style.display=loginFrameStatus;
}

function closeLoginFrame() {
  document.getElementById('login-form-header').style.display='none';
}

//vymaze hodnotu elementu (napr. onfocus="clearInput('mujinput','text');")
function clearInput(id, value) {
  if (document.getElementById(id).value == value) {
    document.getElementById(id).value = "";
  }
}

//nastavi hodnotu elementu (napr. onblur="fillInput('mujinput','text');")
function fillInput(id, value) {
  if (document.getElementById(id).value == "") {
    document.getElementById(id).value = value;
  }
}



//nastaveni fotogalerie
var rotate_delay = 3000; // delay in milliseconds
current = 1;

function next() {
  if (current<imagesCount) {
    current++;
    self.document['gallery'].src = eval("imageNahled"+current+".src");
    document.getElementById('imageNumber').innerHTML = current;
    document.getElementById('popis').innerHTML = eval("imageNahled"+current+".alt");
  }
}

function previous() {
  if (current > 1) {
    current--;
    document.images.gallery.src = eval("imageNahled"+current+".src");
    document.getElementById('imageNumber').innerHTML = current;
    document.getElementById('popis').innerHTML = eval("imageNahled"+current+".alt");
  }
}

function first() {
  current = 1;
  document.images.gallery.src = eval("imageNahled"+current+".src");
  document.getElementById('imageNumber').innerHTML = current;
  document.getElementById('popis').innerHTML = eval("imageNahled"+current+".alt");
}

function last() {
  current = imagesCount;
  document.images.gallery.src = eval("imageNahled"+current+".src");
  document.getElementById('imageNumber').innerHTML = current;
  document.getElementById('popis').innerHTML = eval("imageNahled"+current+".alt");
}

function ap(text) {
  document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
  rotate();
}

function change() {
  current = document.slideform.slide.selectedIndex;
  document.images.show.src = document.slideform.slide[current].value;
}

function rotate() {
  if (document.slideform.slidebutton.value == "Stop") {
    current = (current == document.slideform.slide.length-1) ? 0 : current+1;
    document.images.show.src = document.slideform.slide[current].value;
    document.slideform.slide.selectedIndex = current;
    window.setTimeout("rotate()", rotate_delay);
   }
}

function showImageNewWindow() {
  var image = eval("image"+current);
  makeNewWindow(image.src,image.width,image.height);
}

function schovatCook(i,name){
  if (i.style.display=='none'){
    i.style.display='';
    nastavCookie(name);
  }
  else {
    i.style.display='none'
    nastavCookie(name);
  }
}

function schovat(i,name){
  var hodnota = readCookie(name);
  if (hodnota =='on') {
    document.getElementById(name).style.display = "none";
  }
}

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 nastavCookie(name){
  //nacteni
  var hodnota = readCookie(name);
  if (hodnota=='on') {
    document.cookie = name+'=mazu to tu; expires=Fri, 27 Jul 2010 02:47:11 UTC';

  } else {
    var vyprs=new Date();
    vyprs.setDate(vyprs.getDate() - 365);
    document.cookie = name+'=on; expires=Fri, 27 Jul 2010 02:47:11 UTC';
  }
}




/* parseUri JS v0.1.1, by Steven Levithan <http://stevenlevithan.com>
Splits any well-formed URI into the following parts (all are optional):
----------------------
- source (since the exec method returns the entire match as key 0, we might as well use it)
- protocol (i.e., scheme)
- authority (includes both the domain and port)
  - domain (i.e., host; can be an IP address)
  - port
- path (includes both the directory path and filename)
  - directoryPath (supports directories with periods, and without a trailing backslash)
  - fileName
- query (does not include the leading question mark)
- anchor (i.e., fragment) */
function parseUri(sourceUri){
	var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"],
		uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri),
		uri = {};
	
	for(var i = 0; i < 10; i++){
		uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
	}
	
	/* Always end directoryPath with a trailing backslash if a path was present in the source URI
	Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key */
	if(uri.directoryPath.length > 0){
		uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
	}
	
	return uri;
}

function strpos(haystack, needle, offset) {
    // Finds position of first occurrence of a string within another  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strpos    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14    
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function zobraz(name){
  if (document.getElementById(name).style.display=='none'){
    document.getElementById(name).style.display = "";
  }
  else {
    document.getElementById(name).style.display = "none";
  }
}



