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(Ajax.JS_spominame_titulok);
		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;
}

/***********************************************
* 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(Ajax.JS_spominame_email)
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);}
// -->



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 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;
}

/**********************/
/* 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))
		var ok = true;
	else {
		alert(Ajax.JS_spominame_main_photo);
		return false;
	}
	return ok;
	//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;
	*/
}



// 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 **/
/***********************/
/*


***************************************************************/
//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) {
	
	var left = (screen.width/2)-(300/2);
	var top = (screen.height/2)-(100/2);

	
	window.open("/unifile.php?fti=uploadcsimage&csid="+csid+"&pr="+property+"&sz="+size, "uploadwindow", "width=300,height=100, top="+top+", left="+left+", 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;
}

/*
Funkcia na kontrolu formulara pri odoslani clanku v useroch
*/
function checkArticle() {
	if(document.getElementById('title').value.match(/^\s*$/)) {
		document.getElementById('title').focus();
		alert(Ajax.JS_spominame_titulok);
		return false;
	} else {
		return true;
	}

}

