function showwnd(url,wnd,width,height)
{
	return window.open(url,'',"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2));
}

function changeCheckBox(control,checked) {
    if (checked==2) {
        var val=document.getElementById(control).checked;
        if (val==true) val=false; else val=true;
    } else {
        val=(checked==0)?false:true;
    }

    document.getElementById(control).checked=val;
    document.getElementById(control+"_img").src="http://static.imgsrv.fashion.hu/"+(val?"checkbox_on.gif":"checkbox_off.gif");
    
}
function reload_median() {
	var same=Math.floor(Math.random()*1000000);
	same=same+sameext;
	document.getElementById("median").innerHTML='<!-- Medián WebAudit General Media - myVIP Tech.hu 1/2 --><img style="position:absolute;top:-100px;left:-100px" src="http://audit.median.hu/cgi-bin/track.cgi?uc=12440381177388&dc=1&ui='+same+'" width="1" height="1">';
	
	gemius_hit(pp_gemius_identifier.replace('USED_',''));
}

//A játékok miatt kell
function RefreshMedian() {
	reload_median();
}

function ShowScoreHistory(userid) {
    window.open("score.php?userid="+userid,'w',"resizable=yes,scrollbars=yes,width="+620+",height="+520+",left="+((screen.width-620)/2)+",top="+((screen.height-520)/2));
}
function ShowFaq() {
    window.open("faq.html",'w',"resizable=yes,scrollbars=yes,width="+540+",height="+400+",left="+((screen.width-520)/2)+",top="+((screen.height-400)/2));
}

function showChatWindow(userid) {
    var width=600;
    var height=500;
    
    var wnd= window.open("",'chat_'+userid,"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2)+",toolbar=0,location=0,menubar=0,directories=0,resizable=1");
    
    if (wnd.closedchannel!=null) {
        wnd.focus();
     } else {
        wnd.document.location.href="chat.php?act=newchannel&userid="+userid;
        wnd.focus();
        //window.open("chat.php?act=newchannel&userid="+userid,'chat_'+userid,"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2)+",toolbar=0,location=0,menubar=0,directories=0,resizable=0");
    }
}

function SwitchMenu(menuid) {
	//ki-becsukja a menuid-s almenut
	var m=$('basemenuitems_'+menuid);
	if (m==null) return;
	var b=$('basemenu_'+menuid);
	
	var status;
	if (m.style.display=='none') {
		//kinyitjuk
		m.style.height="auto";
		Effect.BlindDown(m,{duration:0.4});
		status=1;
		b.className=setSubMenuOpen(b.className,true);
		/*b.removeClassName('closed');
		b.addClassName('opened');*/
	} else {
	    m.style.height="auto";
		Effect.BlindUp(m,{duration:0.4});
		status=0;
		b.className=setSubMenuOpen(b.className,false);
		/*b.removeClassName('opened');
		b.addClassName('closed');*/
	}
	
	for (var i=1; i<=12 ; i++) {
		if (i!=menuid && $('basemenuitems_'+i)!=null) 
			//$('menu_'+i).hide();
			if ($('basemenuitems_'+i).visible()) {
			    Effect.BlindUp('basemenuitems_'+i,{duration:0.4});
			    /*$('basemenu_'+i).removeClassName('opened');
	            $('basemenu_'+i).addClassName('closed');*/
			    var b=$('basemenu_'+i);
			    b.className=setSubMenuOpen(b.className,false);
			}
	}
	//new Ajax.Request('main.php', { method: 'get', parameters : {act:'menu',menuid:menuid,status:status}});
}

function setSubMenuOpen(c,open) {
    if (open) c=c.replace(/closed/,"opened");
    else c=c.replace(/opened/,'closed');
    return c;
}

/* Megjelenít egy képet a képernyő közepén (a többit elsötétíti*/
function showPicture(url) {
    if(url=='') return false; //Ha nincs feltöltve kép, akkor nem nagyítunk
    var dim=getWindowDimension();
    var scroll=window.pageYOffset ? window.pageYOffset : 
		document.documentElement ? document.documentElement.scrollTop : 
		document.body ? document.body.scrollTop : 0;
	var div=NewTag('div',document.body);
    div.style.position='absolute';
    div.style.top='0px';
    div.style.left='0px';
    div.style.width='100%';
    div.style.height=getDocumentHeight()+"px";
    div.style.zIndex=10000;
    div.style.background='black';
    SetOpac(div,60);

    var img=NewTag('img',document.body);
    img.src=url;
    img.style.position='absolute';
    var he=((dim.h-500)/dim.h/2)*100;
    var we=((dim.w-500)/dim.w/2)*100;
    img.style.top=(scroll+(dim.h-500)/2)+'px';
    img.style.left=((dim.w-500)/2)+'px';
    img.style.visibility="hidden";
    img.style.zIndex=10002;
    
    
    /*img.style.padding="1px";*/
    img.style.cursor="pointer";
    img.style.margin="auto";
    img.style.width="";
    img.style.height="";
    
    
    img.onclick=function() {
        document.body.removeChild(div);
        document.body.removeChild(this);
        document.body.removeChild(ifr);
    }
    
    img.onload=function() {
    	ifr.style.width=(img.width+2)+'px';
    	ifr.style.height=(img.height+2)+'px';

        var dim=getWindowDimension();
        var scroll=window.pageYOffset ? window.pageYOffset :
            document.documentElement ? document.documentElement.scrollTop :
            document.body ? document.body.scrollTop : 0;
        img.style.top=(scroll+(dim.h-img.height)/2)+'px';
        img.style.left=((dim.w-img.width)/2)+'px';

    	ifr.style.border="0px";
    	ifr.style.background="white";
    	//ifr.style.display="block";
        ifr.style.top=(scroll+(dim.h-img.height)/2)+'px';
        ifr.style.left=((dim.w-img.width)/2)+'px';

    	img.style.border="1px solid white";
        img.style.visibility="visible";
        ifr.style.visibility="visible";
    }
    
    var ifr=NewTag('iframe',document.body);
    ifr.style.position="absolute";
    ifr.style.top=(scroll+(dim.h-500)/2)+'px';
    ifr.style.left=((dim.w-500)/2)+'px';
    ifr.style.zIndex=10001;
    ifr.style.width=img.width;
    ifr.style.height=img.height;
    ifr.style.visibility="hidden";
    
    //ifr.style.display="none";
    reload_median();
}

var popup_data=null;
/* Megjelenít egy popup ablakot */
function showPopup(url, width, height) {
    if (popup_data!=null) hidePopup();
    
    var dim=getWindowDimension();
    var scroll=window.pageYOffset ? window.pageYOffset : 
		document.documentElement ? document.documentElement.scrollTop : 
		document.body ? document.body.scrollTop : 0;
	var div=NewTag('div',document.body);
    div.style.position='absolute';
    div.style.top='0px';
    div.style.left='0px';
    div.style.width='100%';
    div.style.height=getDocumentHeight()+"px";
    div.style.zIndex=10000;
    div.style.background='black';
    SetOpac(div,60);

    var ifr=NewTag('iframe',document.body);
    ifr.style.position="absolute";
    ifr.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    ifr.style.left=Math.max(0,((dim.w-width)/2))+'px';
    ifr.style.zIndex=10001;
    ifr.style.width=(width-5)+'px';
    ifr.style.height=(height-5)+'px';
    
    var content=NewTag('div',document.body);
    content.style.position="absolute";
    content.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    content.style.left=Math.max(0,((dim.w-width)/2))+'px';
    content.style.zIndex=10002;
    content.style.width=width+'px';
    content.style.height=height+'px';
    content.style.background='#B6B6B6';
    content.style.overflow='hidden';
    content.style.border="1px solid white";
    
    var content2=NewTag('div',content);
    content2.style.width=(width-14)+'px';
    content2.style.height=(height-14)+'px';
    content2.id="popupcontent";
    /*content2.style.background='white';*/
    content2.style.overflow='hidden';
    content2.style.margin="2px";
    content2.style.padding= '5px';
    content2.className='popupcontent';
    
    popup_data={'backgrnd': div, 'iframe': ifr, 'content': content};
    
    new Ajax.Updater("popupcontent",url,{method: 'get',evalScripts: true});
    reload_median();
}

/* Megjelenít egy popup ablakot */
function showPopupHTML(html, width, height) {
    if (popup_data!=null) hidePopup();
    
    var dim=getWindowDimension();
    var scroll=window.pageYOffset ? window.pageYOffset : 
		document.documentElement ? document.documentElement.scrollTop : 
		document.body ? document.body.scrollTop : 0;
	var div=NewTag('div',document.body);
    div.style.position='absolute';
    div.style.top='0px';
    div.style.left='0px';
    div.style.width='100%';
    div.style.height=getDocumentHeight()+"px";
    div.style.zIndex=10000;
    div.style.background='black';
    SetOpac(div,60);

    var ifr=NewTag('iframe',document.body);
    ifr.style.position="absolute";
    ifr.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    ifr.style.left=Math.max(0,((dim.w-width)/2))+'px';
    ifr.style.zIndex=10001;
    ifr.style.width=(width-5)+'px';
    ifr.style.height=(height-5)+'px';
    
    var content=NewTag('div',document.body);
    content.style.position="absolute";
    content.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    content.style.left=Math.max(0,((dim.w-width)/2))+'px';
    content.style.zIndex=10002;
    content.style.width=width+'px';
    content.style.height=height+'px';
    content.style.background='white';
    content.style.overflow='hidden';
    content.style.border="1px solid black";
    
    var content2=NewTag('div',content);
    content2.style.width=(width-14)+'px';
    content2.style.height=(height-14)+'px';
    content2.id="popupcontent";
    /*content2.style.background='white';*/
    content2.style.overflow='hidden';
    content2.style.margin="2px";
    content2.style.padding= '5px';
    content2.className='popupcontent';
    
    popup_data={'backgrnd': div, 'iframe': ifr, 'content': content};
    
    $("popupcontent").update(html);
    reload_median();
}

function hidePopup(callback,param) {
    if (popup_data!=null) {
        document.body.removeChild(popup_data.backgrnd);
        document.body.removeChild(popup_data.iframe);
        document.body.removeChild(popup_data.content);
        delete popup_data;
        popup_data=null;
    }
    if (callback!=null) callback(param);
}

function parseToXML(req) {
	var xmlDocument;
	if (!(window.ActiveXObject)) { //For motherfucking Firefox !&}>#&&@#&3&#{&@{
		var responseString = req.responseText;
		var domParser = new DOMParser();
		xmlDocument = domParser.parseFromString(responseString, 'application/xml');
		} else xmlDocument = req.responseXML

	return xmlDocument;
}

function getWindowDimension() {
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        w = window.innerWidth;
        h = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        w = document.documentElement.clientWidth;
        h = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    return {w:w,h:h};
}

function getDocumentHeight() {
    var htmlheight = document.body.parentNode.scrollHeight; 
    var windowheight = window.innerHeight; 
    if ( htmlheight < windowheight ) { return windowheight; } 
    else { return htmlheight; } 
}

//DOM objektumkezelő függvények
function InsertBefore (pParent, pChild, pBefore)
{
    var a = new Array ();
    var c = pParent.firstChild;
    while (c!=null) {
        if (c == pBefore) break;
        c = c.nextSibling;
    }

    while (c!=null) {
        a[a.length] = c;
        c = c.nextSibling;
    }

    var i = 0;
    for (i = 0; i < a.length; i++) {
        pParent.removeChild(a[i]);
    }
    pParent.appendChild(pChild);
    for (i = 0; i < a.length; i++) {
        pParent.appendChild(a[i]);
    }

    delete a;
}

function RefreshChildren (pParent) {
    var a = new Array ();
    var c = pParent.firstChild;
    while (c!=null) {
        a[a.length] = c;
        c = c.nextSibling;
    }
    var i = 0;
    for (i = 0; i < a.length; i++) {
        pParent.removeChild(a[i]);
    }

    for (i = 0; i < a.length; i++) {
        pParent.appendChild(a[i]);
    }

    delete a;
}

function AddTag(pChild, pParent, pBefore) {
    if(pBefore != undefined) InsertBefore (pParent, pChild, pBefore);
    else pParent.appendChild(pChild);
}

function NewTag(id, pParent, pBefore) {
    var tag = document.createElement(id);
    if(pParent != undefined) AddTag(tag, pParent, pBefore);
    return tag;
}

function NewTextTag(text, pParent, pBefore) {
    var tag = document.createTextNode(text);
    if(pParent != undefined) AddTag(tag, pParent, pBefore);
    return tag;
}

function SetOpac (block,value) {
	block.style.opacity = value/100;
	block.style.filter = 'alpha(opacity=' + value + ')';
}   
 
function correctPNG() {// correctly handle PNG transparency in Win IE 5.5 or higher.
   for(var i=0; i<document.images.length; i++) {
        var img = document.images[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;"  + img.style.cssText;
            if (img.align == "left") imgStyle = "float:left;" + imgStyle;
            if (img.align == "right") imgStyle = "float:right;" + imgStyle;
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;    
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
            img.outerHTML = strNewHTML;
            i = i-1;
        }
    }
}

//A jelölgetéseket kezelő rész
function friendlist_Completed(response){
	var friendlists=response.responseXML.getElementsByTagName("friendlist");
	
	for (i=0;i<friendlists.length;i++) {
        var friendlist=friendlists[i];
	    var page=friendlist.getElementsByTagName("page")[0].firstChild.data;
    	var data=friendlist.getElementsByTagName("data")[0].firstChild.data;
    	
    	if (page==0) {
    	    //Kártya
    	    var userid=friendlist.getElementsByTagName("userid")[0].firstChild.data;
    	    Element.replace('usercard'+userid, data);
    	} else document.getElementById("Tabinner"+page).innerHTML=data;
	}
}

//Ezt hívjuk meg, ha a barátjelölés, visszavonás stb. megtörtént
function refresh_usercard(userid) {
    if (userid!=null) {
        new Ajax.Request("contact.php",
        {method: 'get',
         parameters : {
             act:"getusercard",
             userid:userid
         },
         onComplete : function(response) {
             Element.replace('usercard'+userid, response.responseText);
         }
        });
    }
}

function updatecard(response,userid) {
    $('usercard'+userid).innerHTML=response.responseText;
}


function addfriend(userid) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
	showPopup('contact.php?act=addfriend&userid='+userid,400,180);
}

function delfriend(userid,actpage) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
    if (!confirm("Biztosan meg akarod szüntetni az ismeretséget?")) return;
    
    if (document.getElementById("Tabinner1")!=null) tabs=1;
    else tabs=0;

    new Ajax.Request("contact.php", {
	   method: 'GET',
	   parameters: {act:'delfriend', userid: userid, tabs: tabs, p: actpage},
	   onComplete:friendlist_Completed
	});
}

function delfriendrequest(userid,actpage) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
	if (!confirm("Biztosan vissza akarod vonni a jelölést?")) return;
	
	if (document.getElementById("Tabinner1")!=null) tabs=1;
    else tabs=0;

	new Ajax.Request("contact.php", {
	   method: 'GET',
	   parameters: {act:'delfriendrequest', userid: userid, tabs: tabs, p: actpage},
	   onComplete:friendlist_Completed
	});
}

function acceptcandidate(userid,actpage) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
   	if (document.getElementById("Tabinner1")!=null) tabs=1;
    else tabs=0;

    new Ajax.Request("contact.php", {
	   method: 'GET',
	   parameters: {act:'acceptfriendrequest', userid: userid, tabs: tabs, p: actpage},
	   onComplete:friendlist_Completed
	});
}

function refusecandidate(userid,actpage) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
  	if (document.getElementById("Tabinner1")!=null) tabs=1;
    else tabs=0;

    new Ajax.Request("contact.php", {
	   method: 'GET',
	   parameters: {act:'refusefriendrequest', userid: userid, tabs: tabs, p: actpage},
	   onComplete:friendlist_Completed
	});
}

function addignore(userid) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
    showPopup('contact.php?act=addignore&userid='+userid,400,180);
}

function delignore(userid) {
	if (tech_isguest) {
		document.location.href="main.php?act=onlyreg";
		return;
	}
	
    if (!confirm("Biztosan törölni szeretnéd a személyt a tiltólistádról?")) return;
    
    if (document.getElementById("Tabinner1")!=null) tabs=1;
    else tabs=0;

    new Ajax.Request("contact.php", {
	   method: 'GET',
	   parameters: {act:'delignore', userid: userid, tabs: tabs, p: actpage},
	   onComplete:friendlist_Completed
	});
}

function addGoodsFavourite(itemid) {
	new Ajax.Request("/goods.php", {
	   method: 'POST',
	   parameters: {act:'addfavourite', 'itemid': itemid},
	   onComplete:	function (response) {
	   					var itemid=response.responseText;
	   					if (itemid!="0") {
	   						alert("A ketyere bekerült a kedvenceid közé!");
	   						if ($('goodsitem_favourite'+itemid) != null) 
	   								$('goodsitem_favourite'+itemid).update("<a href='javascript:void(0);' onclick='delGoodsFavourite("+itemid+")'>Törlés a kedvencek közül &raquo;</a>");
	   					} else alert("A ketyere már szerepel a kedvenceid között!");
	   				}
	});
}

function delGoodsFavourite(itemid) {
	new Ajax.Request("/goods.php", {
	   method: 'POST',
	   parameters: {act:'delfavourite', 'itemid': itemid},
	   onComplete:	function (response) {
	   					var itemid=response.responseText;
	   					if (itemid!="0") {
	   						alert("A ketyere törlődött a kedvenceid közül!");
	   						if ($('goodsitem_favourite'+itemid) != null) 
	   								$('goodsitem_favourite'+itemid).update("<a href='javascript:void(0);' onclick='addGoodsFavourite("+itemid+")'>Kedvencek közé &raquo;</a>");
	   					} else alert("A ketyere nem szerepel a kedvenceid között!");
	   				}
	});
}

function addGoodsToTechroom(itemid) {
	new Ajax.Request("/techroom.php", {
	   method: 'POST',
	   parameters: {act:'additem', 'itemid': itemid},
	   onComplete:	function (response) {
	   					var res=new String(response.responseText);
	   					if (res=="Ok") {
	   						alert("A ketyere bekerült a techszobádba!");
	   						if ($('goodsitem_techroom'+itemid) != null) 
	   								$('goodsitem_techroom'+itemid).update("");
	   					} else alert(res);
	   				}
	});
}

function delGoodsFromTechroom(itemid) {
	new Ajax.Request("/techroom.php", {
	   method: 'POST',
	   parameters: {act:'delitem', 'itemid': itemid},
	   onComplete:	function (response) {
	   					var itemid=response.responseText;
	   					if (itemid=="0") 
	   					   alert("Ez a ketyere nem szerepel techszobádban!");
	   				}
	});
}

function openGalleryWithFolder(folderid) {
	showwnd('/gallery.php?folderid='+folderid,'', 639,630);
}
function openGalleryWithImage(imageid) {
	showwnd('/gallery.php?imageid='+imageid,'', 639,630);
}


var g_bPngHackSupported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";

function SetTransparentPng(img,src)
{
	var blankSrc = "http://static.imgsrv.tech.hu/empty.gif";
	if(g_bPngHackSupported && img.runtimeStyle)
	{
		if ( /\.png$/.test( src.toLowerCase() ) ) {
			// set blank image
			img.src = blankSrc;
			//img.src= src;
			// set filter
			img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		}
		else {
		// remove filter
			img.runtimeStyle.filter = "";
			img.src=src;
		}
	}
	else img.src=src;
}

// JavaScript Document
techVideo={
	Version: '0.1',
	appear:function(){
	},
	play:function(flv){
	},
	adv_appear:function(flv)
	{
		/*if(!$('count_advvideo'))
		{
			var s=document.createElement('IFRAME');
			s.src="count_advvideo.html";
			s.style["position"]="absolute";
			s.style["left"]="-10000px";
			s.id="count_advvideo";
			document.body.insertBefore(s, document.body.firstChild);
		}*/
	},
	setVolume:function(value)
	{
		setCookie('FlvPlayerVolume', value, 365);
	},
	getVolume:function()
	{
		var r=getCookie('FlvPlayerVolume');
		if(r==null)r=0.75;
		return r;
	},
	get_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		//var r=0.5625;
        var r=0.5625;
		var width="440";
		//var width="560";
		var height="350";
		//var height="342";
		videodesc=escape(videodesc);
		if(autowidth!="default")
		{
			if(autowidth==0)
			{
				//width="100%";
				//height="100%";
			}
			else
			{
				width=autowidth;
				height=Math.round(width*r)+30;
			}
		}
		var advvideostr='';

		if(preurl!='') advvideostr=advvideostr+'&prelink='+preurl;
		if(posturl!='') advvideostr=advvideostr+'&postlink='+posturl;

		var ret = '<object id="videoobject'+videoid+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'">';
		ret += '<param name="movie" value="/player.swf">';
		ret += '<param name="quality" value="high">';
		ret += '<param name="allowFullScreen" value="true">';
		ret += '<param name="allowScriptAccess" value="always">';
		ret += '<param name="FlashVars" value="videoid='+videoid+'&videourl='+videourl+'&picurl='+picurl+'&videodesc='+videodesc+'&mode='+mode+'&needxml=0'+advvideostr+'">';
		ret += '<embed name="videoobject'+videoid+'" src="/player.swf" FlashVars="videoid='+videoid+'&videourl='+videourl+'&picurl='+picurl+'&videodesc='+videodesc+'&mode='+mode+'&needxml=0'+advvideostr+'" quality="high" allowFullScreen=true type="application/x-shockwave-flash" allowScriptAccess="always" width="'+width+'" height="'+height+'">';
		ret += '</object>';
		return(ret);
	},
	print_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		document.write(this.get_flvplayer(videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl));
	},
    set_flvplayer:function (element,videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		$(element).update(this.get_flvplayer(videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl));
	}
}

// JavaScript Document
techVideo2={
	Version: '0.1',
	appear:function(){
	},
	play:function(flv){
	},
	adv_appear:function(flv)
	{
		/*if(!$('count_advvideo'))
		{
			var s=document.createElement('IFRAME');
			s.src="count_advvideo.html";
			s.style["position"]="absolute";
			s.style["left"]="-10000px";
			s.id="count_advvideo";
			document.body.insertBefore(s, document.body.firstChild);
		}*/
	},
	setVolume:function(value)
	{
		setCookie('FlvPlayerVolume', value, 365);
	},
	getVolume:function()
	{
		var r=getCookie('FlvPlayerVolume');
		if(r==null)r=0.75;
		return r;
	},
	get_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl,hqurl,hdurl)
	{
		//var r=0.5625;
        var r=0.5625;
		var width="440";
		//var width="560";
		var height="350";
		//var height="342";
		videodesc=escape(videodesc);
		if(autowidth!="default")
		{
			if(autowidth==0)
			{
				//width="100%";
				//height="100%";
			}
			else
			{
				width=autowidth;
				height=Math.round(width*r)+30;
			}
		}
		var advvideostr='';

		if(preurl!='') advvideostr=advvideostr+'&prelink='+preurl;
		if(posturl!='') advvideostr=advvideostr+'&postlink='+posturl;

        /*
        var ret='<object data="/flash/snagplayer.swf" name="movieflash" id="movieflash" type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="440" height="350">';
        ret+='<param value="#000000" name="bgcolor">';
        ret+='<param value="true" name="allowFullScreen">';
        ret+='<param value="window" name="wmode">';
        ret+='<param value="high" name="quality">';
        ret+='<param value="always" name="allowScriptAccess">';
        ret+='<param value="/flash/snagplayer.swf" name="movie">';
        ret+='<param value="true" name="enableembedcode">';

        ret+='<param value="1_videoid='+videoid+'&1_urlvideosd='+videourl+'&1_urlpic='+picurl+(hqurl ? '&1_urlvideohq='+hqurl :'')+(hdurl ? '&1_urlvideohd='+hdurl : '')+'&1_imagescalemode=1&1_defaultquality=2&1_enablechangequality=true&1_autostart=false&1_enableembedcode=true&numvideo=1&urlskin=/flash/techskin.swf" name="flashvars">';
        ret+='<embed name="movieflash" src="/flash/snagplayer.swf" bgcolor="#000000" FlashVars="1_videoid='+videoid+'&1_urlvideosd='+videourl+'&1_urlpic='+picurl+(hqurl ? '&1_urlvideohq='+hqurl :'')+(hdurl ? '&1_urlvideohd='+hdurl : '')+'&1_imagescalemode=1&1_defaultquality=2&1_enablechangequality=true&1_autostart=false&1_enableembedcode=false&numvideo=1&urlskin=/flash%2Ftechskin.swf" quality="high" allowFullScreen=true type="application/x-shockwave-flash" allowScriptAccess="always" width="'+width+'" height="'+height+'">';

        ret+='</object>';
        */

        // Player with embed code
        var ret='<object data="http://www.tech.hu/flash/snagplayer.swf" name="movieflash" id="movieflash" type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="350" width="440">';
        ret+='<param value="#000000" name="bgcolor">';
        ret+='<param value="true" name="allowFullScreen">';
        ret+='<param value="window" name="wmode">';
        ret+='<param value="high" name="quality">';
        ret+='<param value="always" name="allowScriptAccess">';
	ret+='<param value="http://www.tech.hu/flash/snagplayer.swf" name="movie">';
	ret+='<param value="playerurl=http://www.tech.hu/flash/snagplayer.swf&link=http://www.tech.hu&1_embed=embed&1_url=http://www.tech.hu&1_link=link&1_bb=bb&1_videoid='+videoid+'&1_urlvideosd='+videourl+'&1_urlpic='+picurl+(hqurl ? '&1_urlvideohq='+hqurl :'')+(hdurl ? '&1_urlvideohd='+hdurl : '')+'&1_imagescalemode=1&1_defaultquality=2&1_enablechangequality=true&1_autostart=false&1_enableembedcode=true&numvideo=1&urlskin=http://www.tech.hu/flash/techskin.swf" name="flashvars">';
        ret+='<embed name="movieflash" src="http://www.tech.hu/flash/snagplayer.swf" bgcolor="#000000" flashvars="playerurl=http://www.tech.hu/flash/snagplayer.swf&link=http://www.tech.hu&1_embed=embed&1_url=url&1_link=link&1_bb=bb&1_videoid='+videoid+'&1_urlvideosd='+videourl+'&1_urlpic='+picurl+(hqurl ? '&1_urlvideohq='+hqurl :'')+(hdurl ? '&1_urlvideohd='+hdurl : '')+'&1_imagescalemode=1&1_defaultquality=2&1_enablechangequality=true&1_autostart=false&1_enableembedcode=true&numvideo=1&urlskin=http://www.tech.hu/flash/techskin.swf" quality="high" allowFullScreen=true type="application/x-shockwave-flash" allowScriptAccess="always" width="'+width+'" height="'+height+'">';
        ret+='</object>';
        
        return(ret);
	},
	print_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		document.write(this.get_flvplayer(videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl));
	},
    set_flvplayer:function (element,videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl,hqurl,hdurl)
	{
		$(element).update(this.get_flvplayer(videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl,hqurl,hdurl));
	}
}

function basemenuOver() {
    $('base_menu_dropdown').mousein=true;
    new Effect.Appear($('base_menu_dropdown'),{duration:0.3});
    $('base_menu_rovatok').addClassName("selected");
}
function basemenuOut() {
    $('base_menu_dropdown').mousein=false;
    basemenuOutEffect.delay(0.5);
    $('base_menu_rovatok').removeClassName("selected");
}

function basemenuOutEffect() {
    if ($('base_menu_dropdown').mousein==false) 
        new Effect.Fade($('base_menu_dropdown'),{
            duration:0.3
        });
}

/* start flash detect functions */

function Flashdetect()
{
	this.ver= [-1,0,0];
}

Flashdetect.prototype.getversion = function()
{
	this.ver= [-1,0,0];
	if(navigator.plugins && navigator.mimeTypes.length)
	{
		var x=navigator.plugins["Shockwave Flash"];
		if(x && x.description)
		{
			this.ver = (x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
		}
	}
	else
	{
		try
		{
			var axObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for(var i=3;axObj!=null;i++)
			{
				axObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				this.ver = [i,0,0];
			}
		}
		catch(e){}
	}
	if(axObj)axObj = null;
}

Flashdetect.prototype.version= function()
{
	if(this.ver[0] == -1)
	{
	    this.getversion();
	}
	return (this.ver[0]*1);
}

Flashdetect.prototype.enabled= function()
{
	var must_ver = 1;
	if(arguments.length==1)must_ver = arguments[0];
	if(this.ver[0] == -1)
	{
	    this.getversion();
	}
	return (this.ver[0]*1>=must_ver);
}
/* end flash detect functions */

/*
* chat függvények
* (c) Mónus Péter
*/

var chatTimer;
var chatErrorTimer;
var chatNewMessageTimer;
var flood = false;

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}

function openChat(event)
{
    Event.element(event).stopObserving('click', openChat);
    $('chat_arrow').setAttribute('src', 'http://static.imgsrv.tech.hu/up2.gif#');
    ajaxShowChat();
    Event.element(event).observe('click', closeChat);
}

function closeChat(event)
{
    $('chatbox_error').update("");
    Event.element(event).stopObserving('click', closeChat);
    $('chat_arrow').setAttribute('src', 'http://static.imgsrv.tech.hu/down2.gif#');
    $('chatframe').update("");
    ajaxHideChat();
    Event.element(event).observe('click', openChat);
}

function ajaxNewChatMessage()
{
    if(flood)
    {
        showChatError("Új üzenetet csak 2 mp elteltével küldhetsz");
        $('newmessage').focus(); 
        return false;
    }
    var message = ($('chatframe').innerHTML).trim();
    if(message.length == 0)
    {
        showChatError("Hiba! Nincs megnyitva a chat!");
        return false;
    }
    message = $F('newmessage');
    message = message.trim();
    if(message.length < 1)
    {    
        showChatError("Hiba! Nincs szöveg!");
        $('newmessage').focus(); 
        return false;
    }
    else 
    if(message.length>255)
    {
        showChatError("Hiba! A szöveg legfeljebb 255 karakter hosszú lehet!");
        $('newmessage').focus(); 
        return false;
    }
    else
    {
        new Ajax.Request(
            '/chat.php',
            {
                method: 'post',
                parameters: {
                    'act' : 'new',
                    'message' : message
                },
                requestHeaders: {Accept: 'application/json'},
                onComplete: function(_t){
                    showChatMessages(_t);
                    $('newmessage').value = "";
                    $('newmessage').focus(); 
                    flood = true;
                    var ft = setTimeout("setFlood()", 2000); 
                    countChatChars();
                }
            }
        )
    }
    return false;
}

function setFlood()
{
    flood = false;
}

function ajaxLoadChatMessages()
{
    new Ajax.Request(
        '/chat.php',
        {
            method: 'post',
            parameters: {
                'act' : 'display'
            },
            requestHeaders: {Accept: 'application/json'},
            onComplete: function(_t){
                showChatMessages(_t);                
            }
        }
    )
}

function showChatMessages(_t)
{
    var t=_t.responseJSON;
    var def={'error':1000,'errortext':'a válasz nem JSON formátumú...'};
    var hash=$H(t?t:def);
    if(hash.get('msg_err')){
        showChatError(hash.get('msg_err'));
    }
    else
    {
        var string = "";
        hash.each(function(pair){
                if(pair.key < 20)
                {
                    if(pair.key%2==1)
                        string = grayRow(pair.value[0], pair.value[1], createMessageDate(pair.value[2])) + string;
                    else
                        string = blackRow(pair.value[0], pair.value[1], createMessageDate(pair.value[2])) + string;
                }
            }
        );
        $('chatframe').update(string);
        //alert(string)
    }
    clearChatTimer();
    setChatTimer();
}

function createMessageDate(date)
{
    //yyyy-mm-dd hh:mm:ss
    var honap = date.substr(5,2);
    var nap = date.substr(8,2);
    var ido = date.substr(11);
    var honap_ = "";
    switch(honap)
    {
        case "01": honap_ = "január"; break;
        case "02": honap_ = "február"; break;
        case "03": honap_ = "március"; break;
        case "04": honap_ = "április"; break;
        case "05": honap_ = "május"; break;
        case "06": honap_ = "június"; break;
        case "07": honap_ = "július"; break;
        case "08": honap_ = "augusztus"; break;
        case "09": honap_ = "szeptember"; break;
        case "10": honap_ = "október"; break;
        case "11": honap_ = "november"; break;
        case "12": honap_ = "december"; break;
    }
    return honap_ + " " + nap + ". " + ido;
}

function setChatTimer()
{
    chatTimer = setTimeout("ajaxLoadChatMessages()", 8000);
}

function clearChatTimer()
{
    clearTimeout(chatTimer);
}

function showChatError(errorMessage)
{
    $('chatbox_error').update(errorMessage);
    chatNewMessageTimer = setTimeout("hideChatError()", 2000);
}

function ajaxShowChat()
{
    new Ajax.Request(
        '/chat.php',
        {
            method: 'post',
            parameters: {
                'act' : 'show'
            },
            requestHeaders: {Accept: 'application/json'},
            onComplete: function(_t){
                showChatMessages(_t);                
            }
        }
    )
}

function ajaxHideChat()
{
    new Ajax.Request(
        '/chat.php',
        {
            method: 'post',
            parameters: {
                'act' : 'hide'
            },
            requestHeaders: {Accept: 'application/json'},
            onComplete: function(_t){
                clearChatTimer();                
            }
        }
    )
}

function hideChatError()
{
    $('chatbox_error').update("");
}

function grayRow(username, message, messagedate)
{
    var div = "<div class=\"cf chatGrayRow\""
              + "><span class=\"chatUsername\">" + username + "<span class=\"chatUsername\" style=\"font-weight:normal!important\"> (" + messagedate + ")</span> :<br> </span><span class=\"chatMessage\">"
              + message + "</span></div>";
    return div;
}

function blackRow(username, message, messagedate)
{
    var div = "<div class=\"cf chatBlackRow\" "
              + "><span class=\"chatUsername\">" + username + "<span class=\"chatUsername\" style=\"font-weight:normal!important\"> (" + messagedate + ")</span> :<br> </span><span class=\"chatMessage\">"
              + message + "</span></div>";
    return div;
}

function countChatChars()
{
    var num = $F('newmessage').length;
    $('char_count').update(255-num);
}

function check_hirlevel()
{
    var teljes_nev=$F('teljes_nev').trim();
    var hiremail=$F('hiremail').trim();

    new Ajax.Request('newsletter.php', {
       method: 'post',
       parameters: {teljes_nev: teljes_nev,hiremail: hiremail, act:'check_exist_email'},
       onComplete: function(response) {
            switch(response.responseText)
            {
                case '1':
                        $('repmsg').update('Az E-mail cím hibás!');
                    break;
                case '2':
                        $('repmsg').update('Hibás a Teljes név!');
                    break;
                case '3':
                        $('repmsg').update('Az E-mail cím már foglalt!');
                    break;
                case '4':
                        window.location="newsletter.php?act=newsthanx";
                    break;
            }
       }
    });
}