
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>Pejskar.cz - 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 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/pejskar/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 showLeaderboard() {
  var new_height = 100;
  document.getElementById('leaderboard_iframe').style.height = '100px';
  document.getElementById('leaderboard_iframe').style.display = 'block';
  //document.getElementById('leaderboard_iframe').height = new_height;
}

/*
function kontrola() {
  var text = self.document.forms.inzerce.plemeno.value;
  var je_ok = text != "off";
  if (je_ok == false) {
    if (confirm(\"Nezvolili jste plemeno. Chcete pokračovat?\")) {
      return true;
    } else {
      return false;
    }
  } else {
    return true;
  }
}
*/

/*
AJAX dotaz
id  - id dom objektu kam se vlozi vysledek
url - url volaneho scriptu 
*/
function getText(id,url) {
    
    if (url != 0) {
	    if (window.ActiveXObject) {httpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
        else {httpRequest = new XMLHttpRequest();}
            
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function() {processRequest(id); } ;
        httpRequest.send(null);
    }
    else {document.getElementById(id).innerHTML = "";}
}
function processRequest(id) {
	if (httpRequest.readyState == 4) {
	   if(httpRequest.status == 200) {
          var mistoZobrazeni = document.getElementById(id);
          mistoZobrazeni.innerHTML = httpRequest.responseText;
        }
        else {alert("Chyba pri nacitani stranky "+ httpRequest.status +" : "+ httpRequest.statusText);}
	}
}

function zobraz(name){
  if (document.getElementById(name).style.display=='none'){
    document.getElementById(name).style.display = "";
  }
  else {
    document.getElementById(name).style.display = "none";
  }
}

function AddFavorite(linkObj,addUrl,addTitle) { 
  if (document.all && !window.opera) 
  { 
    window.external.AddFavorite(addUrl,addTitle); 
    return false; 
  } 
  else if (window.opera && window.print) 
  { 
    linkObj.title = addTitle; 
    return true; 
  } 
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) 
  { 
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) 
    { 
      window.sidebar.addPanel(addTitle,addUrl,''); 
      return false; 
    } 
  } 
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.'); 
  return false; 
} 

function iniSchovat(a) {
  var box_array = [];
  box_array[1] = 'clanek-info';
  box_array[2] = 'clanek-galerie';
  box_array[3] = 'clanek-inzeraty';
  box_array[4] = 'clanek-diskuze'; 
  box_array[5] = 'clanek-plemena';
  box_array[6] = 'clanek-stanice';
  
  if (strpos(parseUri(document.location.href).query,'pane=')>0 && a == 0) {
    query = parseUri(document.location.href).query;
    pos = strpos(query,'pane=');
    a = query.substr(pos+5,1);
//          a = parseUri(document.location.href).query;
  } else if (a == 0) {
    a = parseUri(document.location.href).anchor;
  }

  for (var i=1; i<box_array.length; i++) {
    var el = document.getElementById(box_array[i]);
    if (a!='' && el != null) {
      if (a!=i) {
        el.style.display="none";
        document.getElementById('tab'+i).className = '';
      } else {
        el.style.display="block";
        document.getElementById('tab'+i).className='active';
      }
    } else {
      if (el != null && i>1) {
        el.style.display="none";
      } else if (el != null) {
        el.style.display="block";
      }
    }
  }
}
    


//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;
  }
}

/* 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 showhide(name) {
	if (document.getElementById(name).style.display == 'none') {
		document.getElementById(name).style.display = "";
	} else {
		document.getElementById(name).style.display = "none";
	}
}
function showEl(name) {
	document.getElementById(name).style.display = "";
}


function hideEl(name) {
	document.getElementById(name).style.display = "none";
}

function fixedEl(id){
if(document.all){
document.all[id].style.pixelTop = document.body.scrollTop + 70; 
}
}
