function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}



// test UTF-8, tieto znaky maju byt spravne: ľščťžýáíéúď
function schovaj(){
	if(document.getElementById('divik').style.display=='block'){
			document.getElementById('divik').style.display='none';
		}else{
			document.getElementById('divik').style.display='block';	
		}		
}

function check31() {
	if(document.getElementById("titulok").value.length==0){
		document.getElementById("titulok").focus();
		alert("Please enter Title!");
		return false;
	}
	return true;
}

/* registracia affiliate prgramu, kontrola vyplnenia formulara */
function checkRegAff() {
	if($id("aff_name").value.match(/^\s*$/)) {
		$id("aff_name").focus();
		alert("Please, fill your name as a partner name");
		return false;
	}
	if(!$id("aff_email").value.match(/^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,4}$/)) {
		$id("aff_email").focus();
		alert("Please, fill your email correctly");
		return false;
	}
	if($id("aff_password").value.match(/^\s*$/) || !$id("aff_password").value.match(/^.{6,}$/)) {
		$id("aff_password").focus();
		alert("Please, fill your password correctly, at least 6 character long");
		return false;
	}
	if($id("aff_password").value != $id("aff_password2").value) {
		$id("aff_password2").focus();
		alert("Confirmtion password not the same, please correct");
		return false;
	}
	$id("registruj").value = "1";
	return true;
}

/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
var dhtmlgoodies_tooltip = false;
	var dhtmlgoodies_tooltipShadow = false;
	var dhtmlgoodies_shadowSize = 4;
	var dhtmlgoodies_tooltipMaxWidth = 200;
	function showTooltip(e,tooltipTxt)
	{
		if(!dhtmlgoodies_tooltip){
			dhtmlgoodies_tooltip = document.createElement('DIV');
			dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
			dhtmlgoodies_tooltipShadow = document.createElement('DIV');
			dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
			
			document.body.appendChild(dhtmlgoodies_tooltip);
			document.body.appendChild(dhtmlgoodies_tooltipShadow);	
		}
		
		dhtmlgoodies_tooltip.style.display='block';
		dhtmlgoodies_tooltipShadow.style.display='block';
		
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		
		dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
		dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
		dhtmlgoodies_tooltip.style.left = e.clientX + 10 + 'px';
		dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';
		
		
		
		dhtmlgoodies_tooltipShadow.style.left = e.clientX + 10 + dhtmlgoodies_shadowSize + 'px';
		dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
		
		if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
			dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
		}
		
		
		dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
		
		
		
	}
	
	function hideTooltip()
	{
		dhtmlgoodies_tooltip.style.display='none';
		dhtmlgoodies_tooltipShadow.style.display='none';		
	}
	

/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}




<!-- okno na stred!!!
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->

/**************************/
/* Funkcie na registraciu */
/**************************/

var odkazChanged = false;

function check() {
	var reg1 = /^[a-zA-Z0-9]+((-)[a-zA-Z0-9]+)*$/;
	
	var reg2 = /^[a-zA-Z0-9]*$/;
	
	var reg = /^[a-zA-Z0-9_]+([\.\-][a-zA-Z0-9_]+)*@[a-zA-Z0-9_]+([\.\-][a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/;
	if(document.getElementById("email").value.search(reg)==-1) {
		document.getElementById("email").focus();
		alert("Please enter a valid email address!");
		return false;
	}
	if(document.getElementById("password1").value.length < 6) {
		document.getElementById("password1").focus();
		alert("Please enter Password! Min 6 char.");
		return false;
	}
	if(document.getElementById("password1").value!=document.getElementById("password2").value) {
		document.getElementById("password2").focus();
		alert("Wrong Password!");
		return false;
	}
	if(document.getElementById("meno").value.length==0) {
		document.getElementById("meno").focus();
		alert("Please enter First name!");
		return false;
	}
	if(document.getElementById("priezvisko").value.length==0) {
		document.getElementById("priezvisko").focus();
		alert("Please enter Last name!");
		return false;
	}
	if(document.getElementById("odkaz").value.length==0) {
		document.getElementById("odkaz").focus();
		alert("Please enter Name for website!");
		return false;
	}
	if(document.getElementById("odkaz").value.search(reg1) == -1 || document.getElementById("odkaz").value.length < 3) {
		document.getElementById("odkaz").focus();
		alert("Incorrect Name for website. Only [a]-[z], [A]-[Z], [0]-[9] characters and [-]. Min 3 char.");
		return false;
	}
	//storeValues()
	return true;
}

/* ja skusam daco*/
function ahoj() {
	
	var fullname = document.getElementById("fullname").value;
	if(true) odkazChanged = true;
	else odkazChanged = false;
	fullname = removeHTML(fullname);
	document.getElementById("odkazprev").innerHTML = fullname;
	
	
}

function ahoj1() {
	
	var fulltext = document.getElementById("fulltext").value;
	if(true) odkazChanged = true;
	else odkazChanged = false;
	fulltext = removeHTML(fulltext);
	document.getElementById("fulltext1").innerHTML = fulltext;
}


function removeHTML(text) {
	var re = new RegExp("&","g");
	text = text.replace(re,"&amp;");
	re = new RegExp("<","g");
	text = text.replace(re,"&lt;");
	re = new RegExp("  ","g");
	text = text.replace(re,"&nbsp; ");
	re = new RegExp(">","g");
	text = text.replace(re,"&gt;");
	re = new RegExp('"',"g");
	text = text.replace(re,"&quot;");
	re = new RegExp("'","g");
	text = text.replace(re,"&#039;");
	re = new RegExp("\r\n","g");
	text = text.replace(re,"<br />");
	re = new RegExp("\n","g");
	text = text.replace(re,"<br />");
	return text;
}


function removeHTML1(text) {
	var re = new RegExp("&","g");
	text = text.replace(re,"&amp;");
	re = new RegExp("<","g");
	text = text.replace(re,"&lt;");
	re = new RegExp(">","g");
	text = text.replace(re,"&gt;");
	re = new RegExp('"',"g");
	text = text.replace(re,"&quot;");
	re = new RegExp("'","g");
	text = text.replace(re,"&#039;");
	re = new RegExp("\r\n","g");
	text = text.replace(re,"<br />");
	re = new RegExp("\n","g");
	text = text.replace(re,"<br />");
	return text;
}


function returnHTML(text) {
	var re = new RegExp("<br />","g");
	text = text.replace(re,"\n");
	re = new RegExp("&lt;","g");
	text = text.replace(re,"<");
	re = new RegExp("&gt;","g");
	text = text.replace(re,">");
	re = new RegExp("&quot;","g");
	text = text.replace(re,'"');
	re = new RegExp("&#039;","g");
	text = text.replace(re,"'");
	re = new RegExp("&amp;","g");
	text = text.replace(re,"&");
	return text;
}

function ahoj2() {
	
	var dnarodenia = document.getElementById("dc1").value;
	var dumrtia = document.getElementById("dc2").value;
	if(true) odkazChanged = true;
	else odkazChanged = false;
	if(dnarodenia !="" || dumrtia !=""){	
		document.getElementById("datum1").innerHTML = dnarodenia+"&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;"+dumrtia;
	}
}




/*    */



function generateOdkaz() {
	var meno = document.getElementById("meno").value;
	var priezvisko = document.getElementById("priezvisko").value;
	var separator = "-";
	if(meno.length==0 || priezvisko.length==0) separator = "";
	if(!odkazChanged) {
		document.getElementById("odkaz").value = filterASCII(meno + separator + priezvisko);
		var odkaz = document.getElementById("odkaz").value;
		odkaz = removeHTML(odkaz);
		document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".last-memories.com";
	}
}

function filterASCII(str) {
	//alert(str+":"+str.replace(/[^a-zA-Z0-9\-]/gi, ""));
	return str.replace(/[^a-zA-Z0-9\-]/gi, "");
}

function changeOdkaz() {
	var odkaz = filterASCII(document.getElementById("odkaz").value);
	if(document.getElementById("odkaz").value != odkaz)
		document.getElementById("odkaz").value = odkaz;
	if(odkaz!=filterASCII(document.getElementById("meno").value+"-"+document.getElementById("priezvisko").value)) odkazChanged = true;
	else odkazChanged = false;
	odkaz = removeHTML(odkaz);
	document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".last-memories.com";
	return true;
}
/*
function storeValues() {
	storecookie('login',document.getElementById('login').value);
	storecookie('firstname',document.getElementById('firstname').value);
	storecookie('lastname',document.getElementById('lastname').value);
	storecookie('password1',document.getElementById('password1').value);
	storecookie('email',document.getElementById('email').value);
	storecookie('id1',document.getElementById('id1').checked);
//	storecookie('id2',document.getElementById('id2').checked);
	storecookie('titulpred',document.getElementById('titulpred').value);
	storecookie('meno',document.getElementById('meno').value);
	storecookie('meno2',document.getElementById('meno2').value);
	storecookie('priezvisko',document.getElementById('priezvisko').value);
	storecookie('dnarodenia',document.getElementById('dnarodenia').value);
	storecookie('dumrtia',document.getElementById('dumrtia').value);
	storecookie('country',document.getElementById('country').selectedIndex);
	//alert(document.getElementById('country').selectedIndex);
	storecookie('mnarodenia',document.getElementById('mnarodenia').value);
	storecookie('mumrtia',document.getElementById('mumrtia').value);
	storecookie('odkaz',document.getElementById('odkaz').value);
}

function loadValues() {
	document.getElementById('login').value = loadcookie('login');
	document.getElementById('firstname').value = loadcookie('firstname');
	document.getElementById('lastname').value = loadcookie('lastname');
	document.getElementById('password1').value = loadcookie('password1');
	document.getElementById('password2').value = loadcookie('password1');
	document.getElementById('email').value = loadcookie('email');
	if(loadcookie('id1')=="" && loadcookie('id1')=="") {
		//alert("vsetko je prazdne");
		document.getElementById('id1').checked = true;
		document.getElementById('id2').checked = false;
	} else {
		if(loadcookie('id1')=="true") {
			document.getElementById('id1').checked = true;
			//alert("id1=true");
			//alert(document.getElementById('id2').checked);
		}
		else {
			document.getElementById('id2').checked = true;
			//alert("id2 = true");
		}
	}
	document.getElementById('titulpred').value = loadcookie('titulpred');
	document.getElementById('meno').value = loadcookie('meno');
	document.getElementById('meno2').value = loadcookie('meno2');
	document.getElementById('priezvisko').value = loadcookie('priezvisko');
	document.getElementById('dnarodenia').value = loadcookie('dnarodenia');
	document.getElementById('dumrtia').value = loadcookie('dumrtia');
	document.getElementById('country').selectedIndex = loadcookie('country');
	document.getElementById('mnarodenia').value = loadcookie('mnarodenia');
	document.getElementById('mumrtia').value = loadcookie('mumrtia');
	document.getElementById('odkaz').value = loadcookie('odkaz');
}
*/
function storecookie(name,value) {
	document.cookie = name+"="+value;
}

function loadcookie(name) {
	var cookie = document.cookie;
	var pos = cookie.search(name);
	if(pos>-1) {
		var rovnasa = cookie.indexOf("=",pos)+1;
		var ciarka = cookie.indexOf(";",pos);
		if(ciarka==-1) ciarka = cookie.length;
		if(rovnasa>ciarka) return "";
		var value = cookie.substring(rovnasa,ciarka);
		return value;
	} else return "";
}

/*********************************/
/* Funkcie na registraciu koniec */
/*********************************/

/**********************/
/* Funkcie pre userov */
/**********************/

function copyMotto() {
	// najprv rozoberieme value na motto a autor
	var value = document.getElementById("selmotto").value;
	var pos = value.indexOf("#!#");
	if(pos<0) pos = value.lenght;
	var motto = value.substring(0,pos);
	var autor = value.substr(pos+3);
	document.getElementById("motto").value = motto;
	document.getElementById("autor").value = autor;
	if(document.getElementById("selmotto").selectedIndex==1) {
		document.getElementById("autor").readOnly = false;
		document.getElementById("motto").readOnly = false;
	} else {
		document.getElementById("autor").readOnly = true;
		document.getElementById("motto").readOnly = true;
	}
}

function otvorokno() {
	var okno = window.open("http://www.last-memories.com/user/fck.php","fckokno");
}

function checkImageToUpload(imgobj) {
	if(imgobj.value == "")
		return true;
	if(imgobj.value.match(/.jpg$/i) || imgobj.value.match(/.jpeg$/i) || imgobj.value.match(/.gif$/i) || imgobj.value.match(/.png$/i))
		return true;
	else {
		alert("Incorrect file format in section LEAD PHOTO,\nPlease choose another image type (.jpg, .jpeg, .gif, .png)");
		return false;
	}
	//if(document.getElementById("musicsend").value
	/*
	if(imgobj.value.indexOf("bmp") == imgobj.value.length - 3 || imgobj.value.indexOf("BMP") == imgobj.value.length - 3) {
		if(imgobj.id == "mainpict")
			alert("Incorrect file format in LEAD PHOTO, Windows Bitmap type of file (.bmp extension) is not allowed,\nplease choose another image type (.jpg, .gif, .png)");
		return false;
	}
	return true;
	*/
}

function checkMusicToUpload(mscobj) {
	if(mscobj.value == "")
		return true;
	if(mscobj.value.match(/.mp3$/i))
		return true;
	else {
		alert("Incorrect file format in section MUSIC ON WEBSITE,\nPlease choose another music format (.mp3)");
		return false;
	}
	//if(document.getElementById("musicsend").value
	/*
	if(imgobj.value.indexOf("bmp") == imgobj.value.length - 3 || imgobj.value.indexOf("BMP") == imgobj.value.length - 3) {
		if(imgobj.id == "mainpict")
			alert("Incorrect file format in LEAD PHOTO, Windows Bitmap type of file (.bmp extension) is not allowed,\nplease choose another image type (.jpg, .gif, .png)");
		return false;
	}
	return true;
	*/
}

function checksubpagetext() {
	if(document.getElementById("authorname").value.match(/^\s*$/)) {
		document.getElementById("authorname").focus();
		alert("Please fill the name");
		return false;
	}
	
	var reg = /^[a-zA-Z0-9_]+([\.\-][a-zA-Z0-9_]+)*@[a-zA-Z0-9_]+([\.\-][a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/;
	if(document.getElementById("authoremail").value != ""){
		if(document.getElementById("authoremail").value.search(reg)==-1) {
			document.getElementById("authoremail").focus();
			alert("Please enter a valid email address!");
			return false;
		}
	}
	
	document.getElementById("somrobot").value = false;
	
	document.getElementById("posli").style.display = "none";
	document.getElementById("posli123").style.display = "block";
	return true;
}

// dlzka retazca v textarea!!!!
/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

/*   END Textarea Maxlength script */



/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
	
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox


/***********************/
/** BROWSER DETECTION **/
/***********************/
/*
Script Name: Full Featured Javascript Browser/OS detection
Authors: Harald Hope, Tapio Markula, Websites: http://techpatterns.com/
http://www.nic.fi/~tapio1/Teaching/index1.php3
Script Source URI: http://techpatterns.com/downloads/javascript_browser_detection.php
Version 4.2.2
Copyright (C) 08 July 2005

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

Lesser GPL license text:
http://www.gnu.org/licenses/lgpl.txt

Coding conventions:
http://cvs.sourceforge.net/viewcvs.py/phpbb/phpBB2/docs/codingstandards.htm?rev=1.3
*/

/*************************************************************
Full version, use it if you are pushing css to its functional limits, and/or are using 
specialized javascript.

Remember, always use method or object testing as your first choice, for example, if ( dom ) { statement; };

This browser detection includes all possibilities I think for most browsers.
Let me know if you find an error or a failure to properly detect, or if there
is a relevant browser that has special needs for detection at our tech forum:
http://techpatterns.com/forums/forum-11.html
The main script is separated from the initial netscape 4 detection due to certain bugs in
netscape 4 when it comes to unknown things like d.getElementById. The variable declarations
of course are made first to make sure that all the variables are global through the page, 
otherwise a javascript error will occur because you are trying to use an undeclared variable.

We test for both browser type (ie, op, or moz/netscape > 6) and version number, then place 
the version number into a variable which can be tested for < or > values, such as 
if (moz && nu> 1.1){....statement....;}
This seems quite reliable, especially for Opera and Mozilla, where there is no other
easy way to get the actual version number.

For more in depth discussion of css and browser issues go to:
http://www.nic.fi/~tapio1/Teaching/DynamicMenusb.php#detections
http://www.nic.fi/~tapio1/Teaching/FAQ.php3

***************************************************************/
//initialization, browser, os detection
var d, dom, nu='', brow='', ie, ie4, ie5, ie5x, ie6, ie7;
var ns4, moz, moz_rv_sub, release_date='', moz_brow, moz_brow_nu='', moz_brow_nu_sub='', rv_full=''; 
var mac, win, old, lin, ie5mac, ie5xwin, konq, saf, op, op4, op5, op6, op7;

d=document;
n=navigator;
nav=n.appVersion;
nan=n.appName;
nua=n.userAgent;
old=(nav.substring(0,1)<4);
mac=(nav.indexOf('Mac')!=-1);
win=( ( (nav.indexOf('Win')!=-1) || (nav.indexOf('NT')!=-1) ) && !mac)?true:false;
lin=(nua.indexOf('Linux')!=-1);
// begin primary dom/ns4 test
// this is the most important test on the page
if ( !document.layers )
{
	dom = ( d.getElementById ) ? d.getElementById : false;
}
else { 
	dom = false; 
	ns4 = true;// only netscape 4 supports document layers
}
// end main dom/ns4 test

op=(nua.indexOf('Opera')!=-1);
saf=(nua.indexOf('Safari')!=-1);
konq=(!saf && (nua.indexOf('Konqueror')!=-1) ) ? true : false;
moz=( (!saf && !konq ) && ( nua.indexOf('Gecko')!=-1 ) ) ? true : false;
ie=((nua.indexOf('MSIE')!=-1)&&!op);
if (op)
{
	str_pos=nua.indexOf('Opera');
	nu=nua.substr((str_pos+6),4);
	brow = 'Opera';
}
else if (saf)
{
	str_pos=nua.indexOf('Safari');
	nu=nua.substr((str_pos+7),5);
	brow = 'Safari';
}
else if (konq)
{
	str_pos=nua.indexOf('Konqueror');
	nu=nua.substr((str_pos+10),3);
	brow = 'Konqueror';
}
// this part is complicated a bit, don't mess with it unless you understand regular expressions
// note, for most comparisons that are practical, compare the 3 digit rv nubmer, that is the output
// placed into 'nu'.
else if (moz)
{
	// regular expression pattern that will be used to extract main version/rv numbers
	pattern = /[(); \n]/;
	// moz type array, add to this if you need to
	moz_types = new Array( 'Firebird', 'Phoenix', 'Firefox', 'Galeon', 'K-Meleon', 'Camino', 'Epiphany', 
		'Netscape6', 'Netscape', 'MultiZilla', 'Gecko Debian', 'rv' );
	rv_pos = nua.indexOf( 'rv' );// find 'rv' position in nua string
	rv_full = nua.substr( rv_pos + 3, 6 );// cut out maximum size it can be, eg: 1.8a2, 1.0.0 etc
	// search for occurance of any of characters in pattern, if found get position of that character
	rv_slice = ( rv_full.search( pattern ) != -1 ) ? rv_full.search( pattern ) : '';
	//check to make sure there was a result, if not do  nothing
	// otherwise slice out the part that you want if there is a slice position
	( rv_slice ) ? rv_full = rv_full.substr( 0, rv_slice ) : '';
	// this is the working id number, 3 digits, you'd use this for 
	// number comparison, like if nu >= 1.3 do something
	nu = rv_full.substr( 0, 3 );
	for (i=0; i < moz_types.length; i++)
	{
		if ( nua.indexOf( moz_types[i]) !=-1 )
		{
			moz_brow = moz_types[i];
			break;
		}
	}
	if ( moz_brow )// if it was found in the array
	{
		str_pos=nua.indexOf(moz_brow);// extract string position
		moz_brow_nu = nua.substr( (str_pos + moz_brow.length + 1 ) ,3);// slice out working number, 3 digit
		// if you got it, use it, else use nu
		moz_brow_nu = ( isNaN( moz_brow_nu ) ) ? moz_brow_nu = nu: moz_brow_nu;
		moz_brow_nu_sub = nua.substr( (str_pos + moz_brow.length + 1 ), 8);
		// this makes sure that it's only the id number
		sub_nu_slice = ( moz_brow_nu_sub.search( pattern ) != -1 ) ? moz_brow_nu_sub.search( pattern ) : '';
		//check to make sure there was a result, if not do  nothing
		( sub_nu_slice ) ? moz_brow_nu_sub = moz_brow_nu_sub.substr( 0, sub_nu_slice ) : '';
	}
	if ( moz_brow == 'Netscape6' )
	{
		moz_brow = 'Netscape';
	}
	else if ( moz_brow == 'rv' || moz_brow == '' )// default value if no other gecko name fit
	{
		moz_brow = 'Mozilla';
	} 
	if ( !moz_brow_nu )// use rv number if nothing else is available
	{
		moz_brow_nu = nu;
		moz_brow_nu_sub = nu;
	}
	if (n.productSub)
	{
		release_date = n.productSub;
	}
}
else if (ie)
{
	str_pos=nua.indexOf('MSIE');
	nu=nua.substr((str_pos+5),3);
	brow = 'Microsoft Internet Explorer';
}
// default to navigator app name
else 
{
	brow = nan;
}
op5=(op&&(nu.substring(0,1)==5));
op6=(op&&(nu.substring(0,1)==6));
op7=(op&&(nu.substring(0,1)==7));
op8=(op&&(nu.substring(0,1)==8));
op9=(op&&(nu.substring(0,1)==9));
ie4=(ie&&!dom);
ie5=(ie&&(nu.substring(0,1)==5));
ie6=(ie&&(nu.substring(0,1)==6));
ie7=(ie&&(nu.substring(0,1)==7));
// default to get number from navigator app version.
if(!nu) 
{
	nu = nav.substring(0,1);
}
/*ie5x tests only for functionavlity. dom or ie5x would be default settings. 
Opera will register true in this test if set to identify as IE 5*/
ie5x=(d.all&&dom);
ie5mac=(mac&&ie5);
ie5xwin=(win&&ie5x);
/********************************************************
here is a sample use of the browser detector, it would load a browser specific stylesheet
for certain unsupported or improperly supported mac ie 5 css styles. The depth variable
is used so that the javascript library file can be used from anywhere in the website, you simply
insert the depth of the file like this, 
...
 <head>
 <title>Browser information Page</title>

 <meta http-equiv = "Content-Type" content = "text/html; charset = iso-8859-1" />
 <link rel = "stylesheet" type = "text/css" href = "css/main.css" />
 <script type = "text/javascript" src = "/js/browser_detection.js"> </script>
 <script type = "text/javascript>browser_css( ); </script>
 </head>

in the head of the web page after the js file is loaded.
Or if you are always referring your site to the root, you wouldn't need that
 and could delete the depth variable and just use the absolute path to the root.

function browser_css( ) {
	d = document;
	if ( ie5mac ) {
		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ie5mac.css" />');
	}
	else if ( document.layers ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ns4x.css" />');
	}
	else if ( ie4 ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ie4.css" />');
	}
	else if ( moz && ( nu < 1 ) ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/moz_pre1-0.css" />');
	}
	else {
		d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/moz5.css" />');
	}
}
*/
/******************************/
/** KONIEC BROWSER DETECTION **/
/******************************/
// LIVE MENENIE STYLOV (RUKA MI ODPADAVA ZE POUZIVAM CUDZIE RIESENIE)
// <!--
var doAlerts=false;
function changeSheets(whichSheet, act_variant){
	if(document.styleSheets){
		var rx = new RegExp('\/'+act_variant+'\/');
		if(!whichSheet.toString().match(rx)) {
			alert("You have selected Style from another variant of Styles, therefore your new Style will be applied after saving your setup.");
			return;
		} else {
			var c = stylesheetcount;
			// if (doAlerts) alert('Change to Style '+(whichSheet+1));
			for(var i=0;i<=c;i++){
				if(document.styleSheets.item(i).href != whichSheet){
					document.styleSheets.item(i).disabled=true;
				}else{
					document.styleSheets.item(i).disabled=false;
				}
			}
		}
	}
}
//-->

function $id(id) {
	if(document.getElementById(id)==null || document.getElementById(id)=="undefined")
		return false;
	else return document.getElementById(id);
}

function urlencode(str) {
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

/* funckie pre customstyleedit v subdomene */
function cs_openuploadwindow(csid, property, size) {
	window.open("/unifile.php?fti=uploadcsimage&csid="+csid+"&pr="+property+"&sz="+size, "uploadwindow", "width=300,height=200,locationbar=0,statusbar=0,menubar=0");
}

function cs_updateImage(imgname, path, property, w, h, pomer, sizew, sizeh) {
  var imgWidth = Math.round(w/pomer);
  var imgHeight = Math.round(h/pomer);
  var selector = document.getElementById("selector"+property); 
	document.getElementById("pomer"+property).value = pomer;
	document.getElementById("updimg"+property).src = path+imgname;
	document.getElementById("updimg"+property).style.width = imgWidth+"px";
	document.getElementById("updimg"+property).style.height = imgHeight+"px";
	document.getElementById("updimg"+property).style.display = "block";
	document.getElementById("insimg"+property).src = path+imgname;
	document.getElementById("insimg"+property).style.width = imgWidth+"px";
	document.getElementById("insimg"+property).style.height = imgHeight+"px";
	document.getElementById("insimg"+property).style.display = "block";
	document.getElementById("insimg"+property).style.left = "-1px";
	document.getElementById("insimg"+property).style.top = "-1px";
  var selectorWidth = Math.round(sizew/pomer) - 2;
  var selectorHeight = Math.round(sizeh/pomer) - 2;
  selectorWidth = imgWidth < selectorWidth ? imgWidth - 2 : selectorWidth;
  selectorHeight = imgHeight < selectorHeight ? imgHeight -2 : selectorHeight;
  selector.style.width = selectorWidth + "px";
	selector.style.height = selectorHeight + "px";
	selector.style.zIndex = 100;  
  selector.style.top = "0px";
  selector.style.left = "0px";  
  selector.style.display = "block";  
  selector.style.borderWidth = "1px";
	cs_writeCoordinateString(Math.round((Number(selector.style.width.replace("px","")) + 2)*pomer),Math.round((Number(selector.style.height.replace("px","")) + 2)*pomer),0,0, property);
  // osetruje, aby sa pridalo, len ak uz neexistuje, problem kvoli tomu, ze sa funkcia vola aj z vnutra stranky ked zobrazujem existujuce (nechcem pridat znova), aj z uploadwindow kedy nahravam novy a chcem ho pridat do selectu
	for(var i=0; i < document.getElementById("selimgs"+property).options.length; i++) {
		var data = document.getElementById("selimgs"+property).options[i].value.split("|");
    if(data[0] == imgname) {
			return;
		}
	}
	document.getElementById("selimgs"+property).options[document.getElementById("selimgs"+property).options.length] = new Option(imgname, imgname+"|"+w+"|"+h);
  document.getElementById("selimgs"+property).selectedIndex = document.getElementById("selimgs"+property).options.length - 1;
	if(document.getElementById("selimgs"+property).style.display == "none")
		document.getElementById("selimgs"+property).style.display = "inline";
}

function cs_callUpdateImage(selImages, path, property, sizew, sizeh) {
  cs_isdrag = false; // vzdy ked zmenime obrazok, tak sa drag zastavi
  if(selImages.value == "") {
  	document.getElementById("updimg"+property).style.width = "0px";
  	document.getElementById("updimg"+property).style.height = "0px";
  	document.getElementById("updimg"+property).style.display = "none";
  	document.getElementById("insimg"+property).style.width = "0px";
  	document.getElementById("insimg"+property).style.height = "0px";
  	document.getElementById("insimg"+property).style.display = "none";
    document.getElementById("selector"+property).style.width = "0px";
  	document.getElementById("selector"+property).style.height = "0px";
    document.getElementById("selector"+property).style.top = "0px";
    document.getElementById("selector"+property).style.left = "0px";  
    document.getElementById("selector"+property).style.display = "none";  
    document.getElementById("selector"+property).style.borderWidth = "0px";
		document.getElementById("coordin"+property).innerHTML = "";
    return false;
  }
  var data = selImages.value.split("|");
  var pagewidth = 700;
  if(document.getElementById("cs_pagewidth"))
    pagewidth = document.getElementById("cs_pagewidth").value;
  var pomer = data[1] / pagewidth;
  if(pomer < 1)
    pomer = 1;
  cs_updateImage(data[0], path, property, data[1], data[2], pomer, sizew, sizeh);
}

function cs_writeCoordinateString(width, height, top, left, property) {
	document.getElementById("coordin"+property).innerHTML = "<b>width:</b>"+width+"px, <b>height:</b>"+height+"px | <b>top:</b>"+top+"px, <b>left:</b>"+left+"px";
}

var cs_isdrag = false;
var cs_dragx = 0;
var cs_dragy = 0;
var cs_relx = 0; // toto urcuje suradnice obrazka v stranke, aby sme mohli pocitat s relativnymi suradnicami nad obrazkom a nie absolutnymi nad strankou, ziskam to pri zmene obrazka ktory chcem editovat
var cs_rely = 0;

function movediv(n,e,property) {
	var selector = document.getElementById("selector"+property);
	var updimg = document.getElementById("updimg"+property);
	var insimg = document.getElementById("insimg"+property);
	var pomer = document.getElementById("pomer"+property).value;
	
	if(!e) e = window.event;
	if(n==1) {
		cs_isdrag = true;
		cs_dragx = e.clientX - selector.offsetLeft;
		cs_dragy = e.clientY - selector.offsetTop;
	}
	if(n==2 && cs_isdrag) {
		if(e.clientX - cs_dragx >= 0 && e.clientX - cs_dragx <= updimg.style.width.replace("px", "") - selector.style.width.replace("px","") - 2) {
			selector.style.left = e.clientX - cs_dragx + "px";
			insimg.style.left = ((-1 * selector.style.left.replace("px","")) - 1) + "px";
		} else if(e.clientX - cs_dragx < 0) {
			selector.style.left = "0px";
			insimg.style.left = "-1px";
    } else if(e.clientX - cs_dragx > updimg.style.width.replace("px", "") - selector.style.width.replace("px","") - 2) {
			selector.style.left = updimg.style.width.replace("px", "") - selector.style.width.replace("px","") - 2;
			insimg.style.left = ((-1 * selector.style.left.replace("px","")) - 1) + "px";
    }
		if(e.clientY - cs_dragy >= 0 && e.clientY - cs_dragy <= updimg.style.height.replace("px", "") - selector.style.height.replace("px","") - 2) {
			selector.style.top = e.clientY - cs_dragy + "px";
			insimg.style.top = ((-1 * selector.style.top.replace("px","")) - 1) + "px";
		} else if(e.clientY - cs_dragy < 0){
			selector.style.top = "0px";
			insimg.style.top = "-1px";
    } else if(e.clientY - cs_dragy > updimg.style.height.replace("px", "") - selector.style.height.replace("px","") - 2) {
			selector.style.top = updimg.style.height.replace("px", "") - selector.style.height.replace("px","") - 2;
			insimg.style.top = ((-1 * selector.style.top.replace("px","")) - 1) + "px";
    }
		cs_writeCoordinateString(Math.round((Number(selector.style.width.replace("px","")) + 2)*pomer),Math.round((Number(selector.style.height.replace("px","")) + 2)*pomer),Math.round(pomer*selector.style.top.replace("px","")), Math.round(pomer*selector.style.left.replace("px","")), property);
    document.getElementById('selectorData'+property).value = Math.round((Number(selector.style.width.replace("px","")) + 2)*pomer)+","+Math.round((Number(selector.style.height.replace("px","")) + 2)*pomer) + "," + Math.round(pomer*selector.style.top.replace("px","")) + "," + Math.round(pomer*selector.style.left.replace("px",""));
  }
	if(n==3) {
		cs_isdrag = false;
	}
}

function cancelBubbleEvent(evt) {
    if (window.event)
        window.event.cancelBubble = true;
    else {
        evt.preventDefault();
        evt.stopPropagation();
        }
    return false;
}

// toto sa vobec nepouziva, ale sral som sa s tym tak dlho, ze mi je luto vymazat, takze to tu bude a keby som to niekedy niekde potreboval, tak budem vediet, ze to tu je :)
function getClipString(curr, t, r, b, l) {
	var data = curr.substr(5).replace(")","");
  var values = data.split(" ");
  var clipstr = "rect(";
  for(var i=0; i<values.length; i++) {
    switch(i) {
    case 0: if(t!=null)
              values[0] = t+"px";
            clipstr += values[0]+" ";
            break;
    case 1: if(r!=null)
              values[1] = r+"px";
            clipstr += values[1]+" "
            break;
    case 2: if(b!=null)
              values[2] = b+"px";
            clipstr += values[2]+" "
            break;
    case 3: if(l!=null)
              values[3] = l+"px";
            clipstr += values[3]
            break;
    }
  }
  clipstr += ")";
  return clipstr;
}

function generateOdkaz1() {
	var meno = document.getElementById("meno").value;
	var priezvisko = document.getElementById("priezvisko").value;
	var separator = "-";
	if(meno.length==0 || priezvisko.length==0) separator = "";

	if(!odkazChanged) {
		document.getElementById("odkaz").value = filterASCII(meno + separator + priezvisko);
		
		document.getElementById("odkaz_ok").style.color = "#73858f";
		
		var odkaz = document.getElementById("odkaz").value;
		odkaz = removeHTML(odkaz);
		document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".last-memories.com";
		if(meno.length == 0){
			document.getElementById("odkaz_ok").innerHTML = "";
			document.getElementById("odkaz_ok").style.backgroundColor = "transparent";
			document.getElementById("odkaz_ok").style.borderWidth = "0";
			document.getElementById("odkaz_ok").style.borderColor = "transparent";
		}
		else if(odkaz.length < 3) {
			document.getElementById("odkaz_ok").innerHTML = "Minimum 3 characters";
			document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
			document.getElementById("odkaz_ok").style.borderWidth = "1";
			document.getElementById("odkaz_ok").style.borderColor = "#616161";
		}
		else if(odkazAvailable(odkaz)) {
			document.getElementById("odkaz_ok").innerHTML = "Available";
			document.getElementById("odkaz_ok").style.color = "#007700";
			document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
		    document.getElementById("odkaz_ok").style.borderWidth = "1";
		    document.getElementById("odkaz_ok").style.borderColor = "#616161";
		} else {
			document.getElementById("odkaz_ok").innerHTML = "Not available";
			document.getElementById("odkaz_ok").style.color = "#aa0000";
			document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
		    document.getElementById("odkaz_ok").style.borderWidth = "1";
		    document.getElementById("odkaz_ok").style.borderColor = "#616161";
		}
		//var odkaz = document.getElementById("odkaz").value;
		//odkaz = removeHTML(odkaz);
		//document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".pets-memories.com";
	}
}

function filterASCII(str) {
	//alert(str+":"+str.replace(/[^a-zA-Z0-9\-]/gi, ""));
	return str.replace(/[^a-zA-Z0-9\-]/gi, "");
}

function changeOdkaz1() {
	var odkaz = filterASCII(document.getElementById("odkaz").value);
	if(document.getElementById("odkaz").value != odkaz)
		document.getElementById("odkaz").value = odkaz;
	if(odkaz!=filterASCII(document.getElementById("meno").value+"-"+document.getElementById("priezvisko").value)) odkazChanged = true;
	else odkazChanged = false;
	odkaz = removeHTML(odkaz);
	
	document.getElementById("odkaz_ok").style.color = "#73858f";
	document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".last-memories.com";
	if(odkaz.length == 0){
		document.getElementById("odkaz_ok").innerHTML = "";
		document.getElementById("odkaz_ok").style.backgroundColor = "";
		document.getElementById("odkaz_ok").style.borderWidth = "0";
		document.getElementById("odkaz_ok").style.borderColor = "";
	}
	else if(odkaz.length < 3){
		document.getElementById("odkaz_ok").innerHTML = "Minimum 3 characters";
		document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
		document.getElementById("odkaz_ok").style.borderWidth = "1";
		document.getElementById("odkaz_ok").style.borderColor = "#616161";
	}
	else if(odkazAvailable(odkaz)) {
		document.getElementById("odkaz_ok").innerHTML = "Available";
		document.getElementById("odkaz_ok").style.color = "#007700";
		document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
		document.getElementById("odkaz_ok").style.borderWidth = "1";
		document.getElementById("odkaz_ok").style.borderColor = "#616161";
	} 
	else {
		document.getElementById("odkaz_ok").innerHTML = "Not available";
		document.getElementById("odkaz_ok").style.color = "#aa0000";
		document.getElementById("odkaz_ok").style.backgroundColor = "#FEFFF2";
		document.getElementById("odkaz_ok").style.borderWidth = "1";
		document.getElementById("odkaz_ok").style.borderColor = "#616161";
	}
		
	//document.getElementById("odkazprev").innerHTML = "http://"+odkaz+".pets-memories.com";
	return true;
}
