function gete(id) {
	return document.getElementById(id);
}

var php_default_value = '-';
function inplace_edit(obj, val) {
	if (typeof val == 'undefined') val = '';

	if (obj.id.match(/inptitle/)) {
		var inp = document.createElement('textarea');
		inp.className = 'inplace';
		inp.innerHTML = val;
	} else {
		var inp = document.createElement('input');
		inp.className = 'inplace';
		inp.setAttribute('type', 'text');
		inp.value = val;
	}

	var objheight = obj.scrollHeight;
	if (objheight < 14) objheight = 14;

	inp.setAttribute('id', obj.id);
	inp.style.height = objheight+'px';
	inp.last_value = (val ? val : php_default_value);

	var par = obj.parentNode;
	par.innerHTML = '';
	par.appendChild(inp);
	inp.focus();

	inp.inplace_save = function() {
		xajax_mycost_inplace_save(this.id, this.value);
	}

	inp.onblur = function() {
		var val = this.value.replace(/ /g, "");
		if (val == '') this.value = this.last_value;
		this.inplace_save();
	}

	inp.onkeydown = function(event) {
		if (typeof event != "undefined") var ch = event.keyCode; else ch = 0;
		if (ch == 27) { this.value = this.last_value; this.blur(); }
		if (ch == 13) this.blur();
	}

}

function costlist_toggle(obj, cat_id) {
	if (obj.className.match(/opened/)) {
		obj.className = 'cat_closed';
	} else {
		obj.className = 'cat_opened';
	}
	showhideelement('costlist_catblock_'+cat_id);
}

function normalize_height(id_base,num,padding) {
	var max_h = 0;
	var h = 1;

	for (i = 1; i <= num; i++) {
		h = document.getElementById(id_base+i).scrollHeight;
		if (h > max_h) max_h = h;
	}

	max_h = max_h - padding * 2;	// + 2*border

	for (i = 1; i <= num; i++) document.getElementById(id_base+i).style.height = max_h + 'px';
}

try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

var navChild, origHeight;
if(navigator.appVersion.indexOf("MSIE")!=-1){
    origHeight = 150;
}else{
    origHeight = 150;
}
var cleartime = null;
function menu_closeopen(mode){
    var incdec = 150;
    if(mode){
        if(origHeight>navChild.offsetHeight){
            navChild.style.height = navChild.offsetHeight + incdec + 'px';
        }
    }else{
            navChild = document.getElementById('nav_moved');
            navChild.style.display = 'none';
             document.question.sendername.value='';
             document.question.senderemail.value='';
             document.question.message.value='';
    }
}
function ocMenu(m){
      navChild = document.getElementById('nav_moved');
      if(m!=1){
          //origHeight = navChild.offsetHeight;
          navChild.style.height = 0 + 'px';
          navChild.style.display = 'none';

          var navParent = document.getElementById('nav_move');
          var t = null;
          navParent.onclick = function(){
            navChild.style.display = 'block';
            menu_closeopen(1);
          }
    }else{
        navChild.style.display = 'block';
    }
}
function open_video () {
    window.open('/_video.php','Video','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=600,width=1007');
}

function preview_mail(uid,text){
    window.open('/_previewmail.php?uid='+uid+'&message='+text,'Preview','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=650');
}

function open_gallery (gid,pic) {
    window.open('/gallery.php?id='+gid+'&pic='+pic,'Galéria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=650,width=690');
}
function open_basegallery (gid,pic) {
    window.open('/basegallery.php?id='+gid+'&pic='+pic,'Galéria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=690,width=950');
}
function open_help (node) {
    window.open('/_help.php?node='+node,'Help','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=550');
}

function open_votegallery (gid,pic) {
    window.open('/votegallery.php?id='+gid+'&pic='+pic,'Galéria','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=690,width=785');
}

function forumpost (forumid,topicid,postid,mode) {
    if(mode==1 && forumid){// new topic
    	param = '?forumid='+forumid+'&mode=newtopic';
	}else{
		if(topicid && postid){
			param = '?topicid='+topicid+'&postid='+postid;
		}else if(topicid && !postid){
			param = '?topicid='+topicid;
		}
	}
    if(param){
    	window.open('/_forum.php'+param,'Forumpost','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=550,width=700');
	}
}

function insAtCursor(myField,myValue)
    {
    // IE support
    if (document.selection)
        {
        myField.focus() ;
        sel = document.selection.createRange() ;
        sel.text = myValue ;
        }
    // MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == "0")
        {
        var startPos = myField.selectionStart ;
        var endPos = myField.selectionEnd ;
        myField.value = myField.value.substring(0, startPos)
        + myValue
        + myField.value.substring(endPos, myField.value.length) ;
        }
    else
        {
        myField.value += myValue;
        }
    }

var copy_prev_value;
function copy_value(from,to) {
    f = document.getElementById(from);
    t = document.getElementById(to);
    if (t.value == '' || t.value==copy_prev_value) t.value = f.value;
}

function open_center_layer(element,x,y,mode){
    /*
    mode : 0; absolut középre, x és y a div fele
    mode : 1; a toppos = y;
    mode : 2; a leftpos = x; toppos = y;
    */
	document.getElementById(element).style.display = "none";
	leftpos = 0 ;
    toppos = 0 ;

	if(mode==0){
		/* TOP */
		if(self.pageYOffset){
			yScroll = self.pageYOffset;
		}else if(document.documentElement && document.documentElement.scrollTop){
			yScroll = document.documentElement.scrollTop;
		}else if(document.body){
			yScroll = document.body.scrollTop;
		}
		if (self.innerHeight) {
			inheight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			inheight = document.documentElement.clientHeight;
		} else if (document.body) {
			inheight = document.body.clientHeight;
		}
		toppos = (yScroll + (inheight/2)) - y;
	}else{
		toppos = y;
	}

	if(mode==0){
		/* LEFT */
	    if (screen){
	        leftpos = (document.body.clientWidth/2) - x ;
		}

	    if (leftpos<0)
	        leftpos = 10 ;
	}else if(mode==2){
		leftpos = x;
	}

	document.getElementById(element).style.left = leftpos+'px';
	document.getElementById(element).style.top = toppos+'px';
}

function showmessagebox(mode){
    var elem = (mode==0) ? 'error_message' : 'success_message';
    document.getElementById(elem).style.display = "block" ;
    window.focus() ;

    document.onclick = function(){
    	document.getElementById(elem).style.display = "none" ;
    	window.focus() ;
    	document.onclick = empty ;
	}
}
function empty(){
}


// FLASH MEGJELENÍTÉS

function showflash(file,width,height,bgcolor) {
    document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"'+width+'\" height=\"'+height+'\">');
    document.write('<param name=\"allowScriptAccess\" value=\"always\" />');
    document.write('<param name=\"movie\" value=\"'+file+'\" />');
    document.write('<param name=\"quality\" value=\"high\" />');
    document.write('<param name=\"wmode\" value=\"opaque\" />');
    document.write('<param name=\"bgcolor\" value=\"'+bgcolor+'\" />');
    document.write('<param name=\"swliveconnect\" value=\"true\" />');
    document.write('<param name=\"menu\" value=\"false\" />');
    document.write('<embed src=\"'+file+'\" quality=\"high\" bgcolor=\"'+bgcolor+'\" width=\"'+width+'\" height=\"'+height+'\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"opaque\"  swliveconnect=\"true\" menu=\"false\"/>');
    document.write('</object>');
}

// RADIO BUTTONOK MEGJELÖLT ÉRTÉKÉNEK VISSZAADÁSA
function getradiovalue(radioObj)
	{
	if (!radioObj)
		return "" ;
	var radioLength = radioObj.length ;
	if (radioLength == undefined)
		if (radioObj.checked)
			return radioObj.value ;
		else
			return "" ;
	for (var i = 0; i < radioLength; i++)
        	{
		if (radioObj[i].checked)
			{
			return radioObj[i].value ;
			}
		}
	return "" ;
	}

function showelement(element)
    {
    document.getElementById(element).style.display = "block" ;
    window.focus() ;
    }

function hideelement(element)
    {
    document.getElementById(element).style.display = "none" ;
    window.focus() ;
    }
function hideall(elements){
    var element = elements.split(',');
	for(i=0; i<element.length; i++)	{
		e = element[i];
		if(document.getElementById(e)){
			document.getElementById(e).style.display = "none" ;
		}
	}
    window.focus() ;
}
function showhideelement(element)
    {
    if (document.getElementById(element).style.display=='none')
	showelement(element) ;
    else
	hideelement(element) ;
    window.focus() ;
    }


/* Registration radiobuttons color  */
function radiotextcolor(){
	for(i=0; i<3; i++){
		TEXT = document.getElementById('usertype_' + i);
		if(document.regform.usertype[i].checked){
			TEXT.style.color = "#ff4a89";
		}else{
			TEXT.style.color = "#8f59a3";
		}
	}
}

function web_pattern(gurl,pattern,txt1,txt2,imshow,webchange){
	for(i=1; i<6; i++){
		obj = document.getElementById('p' + i);
		obj2 = document.getElementById('pc' + i);
		kiir = '';
		if(i==pattern){
			document.getElementById('wp').value = i;
			obj.className = 'activepattern';

			kiir += '<a onclick="web_pattern(\''+ gurl +'\','+ i +',\''+ txt1 +'\',\''+ txt2 +'\',\''+ imshow +'\',\''+ webchange +'\');" href="javascript: void(0);" title="'+ webchange +'">';
			kiir += txt2;
			kiir += '</a>';
			kiir += '<a onclick="show_webpattern(\''+ gurl +'\','+ i +');" href="javascript: void(0);" title="'+ imshow +'">';
			kiir += '<img src="frame/zoom_red.gif" alt="'+ imshow +'" />';
			kiir += '</a>';

			obj2.innerHTML = kiir;
		}else{
			obj.className = 'pattern';

			kiir += '<a onclick="web_pattern(\''+ gurl +'\','+ i +',\''+ txt1 +'\',\''+ txt2 +'\',\''+ imshow +'\',\''+ webchange +'\');" href="javascript: void(0);" title="'+ webchange +'">';
			kiir += txt1;
			kiir += '</a>';
			kiir += '<a onclick="show_webpattern(\''+ gurl +'\','+ i +');" href="javascript: void(0);" title="'+ imshow +'">';
			kiir += '<img src="frame/zoom_lilac.gif" alt="'+ imshow +'" />';
			kiir += '</a>';

			obj2.innerHTML = kiir;
		}
	}
}

/*
<a onclick="web_pattern('<?php print $site_globalurl; ?>',<?php print $i ?>,'<?php print _CHANGE0 ?>','<?php print _CHANGE1 ?>');" href="javascript: void(0);" title="<?php print _WEBCHANGE ?>">
	<?php print $activec ?>
</a>
<a onclick="show_webpattern('<?php print $site_globalurl; ?>',<?php print $i ?>);" href="javascript: void(0);" title="<?php print _IAMSHOW ?>">
	<img src="<?php print $activeimg ?>" alt="<?php print _IAMSHOW ?>" />
</a>
*/
function show_webpattern(gurl,p){
	var oImg = window.open('', 'picture', 'statusbar=no,locationbar=no,status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,directories=0,height=582,width=800');
	htmlkiir = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	htmlkiir += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ua" lang="ua">\n';
	htmlkiir += '<head>\n<title>Сплануй своє весілля! - obruchka.com.ua</title>\n<style>body{margin: 0px;}</style></head>\n<body>\n';
	htmlkiir += '<img src="'+ gurl +'frame/sablon_'+ p +'.jpg" alt="webpattern" />';
	htmlkiir += '</body>\n</html>\n';
	oImg.document.write(htmlkiir);
}

function add_websiteurl(){
	wife = document.getElementById('xwf');
	husband = document.getElementById('xhf');
	address = document.getElementById('xa');

	if(address.value.length<1){
		if(wife.value.length>0 && husband.value.length>0){
			address.value = wife.value+" "+husband.value;
		}
	}
}











/* BETŰMÉRET NÖVELÉSE */

var font_size = 16;
var font_orig = 16;

function text_size(size) {
	if (size==1 && font_size < font_orig + 2){
		font_size += 1;
	}else if (size==0 && font_size > font_orig - 3){
		font_size -= 1;
	}
	// lead szövege
	if(document.getElementById('article_lead'))
	document.getElementById('article_lead').style.fontSize = (font_size) + "px";
	// text szövege
	if(document.getElementById('article_text'))
	document.getElementById('article_text').style.fontSize = (font_size) + "px";
}

/* FLASH arg átírás */
function flashfix() {
	var embedArray = document.getElementsByTagName('embed');
	for (i=0;i<embedArray.length;i++) {
		if (embedArray[i].setAttribute) {
            embedArray[i].setAttribute('wmode','opaque');
		}
	}

	var objectArray = document.getElementsByTagName('object');

	for (i=0;i<objectArray.length;i++) {
		if (objectArray[i].setAttribute) {
			objectArray[i].setAttribute('wmode','opaque');
		}

		if (objectArray[i].outerHTML) {
			objectArray[i].outerHTML=objectArray[i].outerHTML;
		}
	}
}
