var $j = jQuery.noConflict();

function showLoginBox() {
	$j('#ajaxLoginBox').show();
	$j.get( '?l1=login&l2=plug_login&l3=main', function(ret) {
		$j('#ajaxLoginBox').html(ret);
		loadReg();
	});
}

function showLBox() {
	$j('#ajRegistration').hide();
	$j('#ajLoginBox').show();
	$j('#bigLoginText').hide();
}

function loadReg() {
	$j('#ajLoginBox').hide();
	if ( $j('#ajRegistration').html() == '' ) {
		$j.get( '?l1=registration&l2=plug_registration&l3=main', function(ret) {
			$j('#ajRegistration').html(ret);
		});
	}
	$j('#ajRegistration').show();
	$j('#bigLoginText').show();
}

function subForm( obj ) {
	/**/
	$j.post(
		obj.action, 
		obj.serialize(),
		function(ret) {
			if ( ret ) alert(ret);
			else contOrder();
		}
	);
	return false;
}

function contOrder() {
	window.location = 'http://www.timecenter.hu/?l1=webstore&l2=plug_webstore_order&l3=main';
}

function openPrint() {
	link = document.location.href;
	if ( link.indexOf('?') == -1 ) {
		link += '?print=1';
	} else {
		link += '&print=1';
	}
	window.open( link, 'PrintWindow', 'width=640,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes')
}

function showLButton(obj) {
	if (obj.value) { $j('#loginSubmit').addClass('loginok'); }
	else $j('#loginSubmit').removeClass('loginok');
}

var outBannerPos = 0;
var outBannerPosBase = 0;
var outBanner = null;
function initBanner() {
	params_list = getWindowParams();
	outBannerPos = ( (params_list['winW']-940)/2 );
	if (!params_list['browser']) {
		outBannerPos -= 10;
	}
	outBanner = document.getElementById('outbanner');
	outBannerPosBase = outBanner.offsetWidth;
	outBanner.style.width = outBannerPos+'px';
	if ( outBannerPos < outBannerPosBase ) {
		addEvent(outBanner, 'mouseover', sBanner);
		addEvent(outBanner, 'mouseout', rBanner);
	}
}

function sBanner() {
	outBanner.style.width = outBannerPosBase+'px';
}

function rBanner() {
	outBanner.style.width = outBannerPos+'px';
}

function getImage(id, obj) {
	obj.src='http://timecenter.portalinternet.hu/ftp/webstore_images/thumb/'+id.toLowerCase()+'.jpg';
}

function disableContextMenu(element) {
	element.oncontextmenu = function() {
		return false;
	}
}

disableContextMenu(document);

shortcut.add("Ctrl+A",function() {return false;})
shortcut.add("Ctrl+C",function() {return false;})
shortcut.add("Ctrl+X",function() {return false;})
shortcut.add("Ctrl+S",function() {return false;})
shortcut.add("pause",function() {return false;})

//0 - házhoz szállítás; 1 - személyes
function setFizetesSel(selId) {
	for(i=0;i<=7;i++) { if ( $('idopont_'+i) ) { $('idopont_'+i).disabled = true; $('atvetel_ido_bolt'+i).style.display = 'none'; } }
	if ( $('idopont_'+selId) ) { $('idopont_'+selId).disabled = false; $('atvetel_ido_bolt'+selId).style.display = 'block'; }
	if(selId) fizSel = selId;
}

var fizType = 0;
var fizSel = -1;
function setFizetes( value ) {

	if ( fizType == value ) {
		return 0;
	}
	fizType = value;

	if ( value ) {
		//Személyes
		$('fizetes_mod_0').disabled = true;
		$('fizetes_mod_1').disabled = false;
		setFizetesSel(fizSel);
	} else {
		//Futár
		$('fizetes_mod_0').disabled = false;
		$('fizetes_mod_1').disabled = true;
		setFizetesSel(0);
	}

	showHide('fizetes_mod_0');
	showHide('fizetes_mod_1');

	showHide('atvetel_sel');
//	showHide('kiszallitas_sel');
}

function checkOrderForm() {
	idopontok = document.getElementsByName('idopont');
	if ( idopontok.length > 0 ) {
		checkIdo = '';
		for(i=0;i<idopontok.length;i++)
			if (!idopontok[i].disabled)
				checkIdo = idopontok[i].value;

		if(!checkIdo) {
			alert('Válassza ki átvétel helyét!');
			return false;
		}
	}
}


function ajaxContentLink(content) {
	var url = window.location.toString();
	linkparams = url.split('#');
	if ( typeof(actCont) == "undefined" ) {
		actCont = null;
	}
	if ( linkparams[1] ) {
		actCont = linkparams[1];
	}
	document.write('<div id="ajaxContent"></div>');
	links = $(content).getElementsByTagName("A");
	for( i=0; i<links.length; i++ ) {
		if (links[i].target == '_blank') {
			links[i].target = '';
		} else {
			links[i].id = links[i].href;
			links[i].removeAttribute('href');
			addEvent(links[i], 'click', getContent);
			if ( links[i].id.indexOf('/'+actCont) != -1 ) {
				loadContent(links[i].id);
				actCont = null;
			}
		}
	}
}

function getContent(e) {
	if (!e) var e = window.event;
	if (e.target) tag = e.target;
	else if (e.srcElement) tag = e.srcElement;
	while( tag.tagName != "A" ) {
		tag = tag.parentNode;
	}

	if ( !tag.id ) {
		return false;
	}
	link = tag.id
	loadContent(link);
}

function loadContent(link) {
	$('ajaxContent').innerHTML = '<p>Kérem várjon</p>';
	new Ajax.Request( link, {
			method: 'get',
			onSuccess: function(new_c) {
				var tmp_c = document.createElement("DIV");
				tmp_c.innerHTML = new_c.responseText;
				$('ajaxContent').innerHTML = new_c.responseText;
				$('center').style.height='auto';
				gotoname = gup('goto');
				if ( gotoname && $(gotoname) ) {
					window.scrollTo(0, getRealTop($(gotoname)));
				}
			}
		}
	);
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function setSzallitasi(trg, type, value ) {
	new Ajax.Request( '?l1=webstore&l2=plug_webstore_order&l3=main&type='+type+'&value='+value, {
			method: 'get',
			onSuccess: function(new_c) {
				$(trg).innerHTML = new_c.responseText;
			}
		}
	);

}

function setEditable( id ) {
	if ( id == 'szallitasi_adatok' ) {
		$('szall_select').style.display = 'block';
	}
	inputs = $(id).getElementsByTagName("input");
	for(i=0; i<inputs.length; i++) {
		inputs[i].className = '';
		inputs[i].onclick = '';
	}
}

function setUnEditable( id ) {
	inputs = $(id).getElementsByTagName("input");
	for(i=0; i<inputs.length; i++) {
		inputs[i].className = 'inactive';
//		inputs[i].onclick = inputs[i].blur();
//		inputs[i].disabled = true;
	}
}

/*Irányítószám*/

var irsz_obj = null;
var irsz_list = null;
var irsz_type;

function initIrsz(obj, bool) {
	irsz_type = bool;
	irsz_obj = obj;
	setTimeout( initIrszDiv, 500 );
}

function initIrszDiv() {
	irsz_obj.onkeyup = function() {
		var url = '?l1=webstore&l2=plug_webstore_order&l3=main&type=cities&value='+irsz_obj.value + '&irsztype=' + irsz_type;
		httpGet(url, callback)
	};
	irsz_obj.onblur = hideList;
	createDiv();
}

function callback(wr) {
	if ( wr.responseText ) {
		if ( irsz_list == null ) {
			createDiv();
		}
		html = document.createElement("DIV");
		html.innerHTML = wr.responseText;
		irsz_list.innerHTML = '';
		irsz_list.appendChild(html);
		irsz_list.style.display = 'block';
		irsz_list.style.position = 'absolute';
	} else {
		irsz_list.style.display = 'none';
	}
}

function createDiv() {
	irsz_list = document.createElement("DIV");
	irsz_list.id = 'cities';
	irsz_list.style.width = irsz_obj.offsetWidth+'px';
	irsz_list.style.left = getRealLeft(irsz_obj)+'px';
	irsz_list.style.top = getRealTop(irsz_obj)+irsz_obj.offsetHeight+1+'px';
	irsz_obj.parentNode.insertBefore(irsz_list, irsz_obj.nextSibling);
	irsz_list = $('cities');
}

function hideDiv() {
	if (irsz_list != null) irsz_list.parentNode.removeChild(irsz_list);
	irsz_list = null;
}

function hideList() {
	setTimeout( hideDiv, 200 );
}

function placeAddress(obj, bool) { //if true, only the city goes into an other input  else the whole text goes into the same input
	if (!bool) irsz_obj.value=obj.innerHTML;
	else {
		var r,s;
		r = new RegExp('[^0-9 ]', 'gi');
		s = obj.innerHTML.replace(r, '');
		irsz_obj.value = s;
		r = new RegExp('[0-9 ]', 'gi');
		s = obj.innerHTML.replace(r, '');
		document.getElementById("city").value = s;
	}
	hideList();
}


function setToEdit( obj ) {
	obj.readOnly = false;
	obj.className = 'edit';
	obj.focus();
}

function setToNotEdit( obj ) {
	obj.readOnly = true;
	obj.className = 'notedit';
}

function getRealTop(el){
	yPos = el.offsetTop;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

function getRealLeft(el){
	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

var cart_thumb_pics_img = null;
function showImage( div, sku ) {

	if( $('cart_thump_pics') ) {
		$('cart_thump_pics').style.position = 'absolute';
		$('cart_thump_pics').style.zIndex = 1000;
		oTop = div.offsetTop-110;
		if ( oTop < 0 ) {
			oTop = getRealTop(div)-110;
		}
		$('cart_thump_pics').style.top = oTop+'px';
		if ( $('cart_thump_pics').style.display != 'block' ) {
			img = $('cart_thump_pics_img');
			img.src = 'ftp/webstore_images/thumb/'+sku.toLowerCase()+'.jpg';
		}
		$('cart_thump_pics').style.display = 'block';
	}
}

function hideImage() {
	$('cart_thump_pics').style.display = 'none';
}

var index_flash_act = 0;
function showIndexFlash( type, w, h, bg ) {
	if ( index_flash_act ) {
		showBanner( 'sablons/cms/pics/', type+'_index', w, h, bg, 'window' );
		$('center').style.display="none";
	}
}

function showIndexPage( type ) {
	if ( index_flash_act ) {
		$('center').style.display="none";
		$('center_index').style.display="block";
		new Ajax.Updater('center_index', 'index/index_'+type+'.html', { method: 'get' });
	}
}

function showFloatImage(e) {
	// IE is retarded and doesn't pass the event object
	if (e == null) e = window.event;

	_posX = e.clientX;
	_posY = e.clientY;

}
// Kisegítő függvények

function getObj(evt) {
	obj = null;

	if ( !evt ) {
		return 0;
	}

	if ( evt['srcElement'] && evt['srcElement']['id'] ) {
		obj = $( evt['srcElement']['id'] );
	} else if ( evt['target'] ) {
		obj = $( evt['target']['id'] );
	}
	return obj;
}

function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function openDiv(id, from, to) {
	div = $(id);
	img = $('bbutton').getElementsByTagName("IMG")[0];
	plusz = 16;
	if ( div.offsetHeight == from+plusz ) {
		if (to) {
			div.style.height = to+'px';
		} else {
			div.style.height = 'auto';
		}
		img.src='sablons/cms/pics/arrow_u.gif';
	} else {
		div.style.height = from+'px';
		img.src='sablons/cms/pics/arrow_d.gif';
	}
}

function showHide( id_name ) {
	obj = $(id_name);
	if ( obj ) {
		if ( obj.style.display=='none' || !obj.style.display ) {
			obj.style.display='block';
		} else {
			obj.style.display='none';
		}
	}
}

function goTo (page) {

	if (page != "" ) {
		document.location.href = page;
	}
	return false;
}

var ypos = 0;

function getWindowParams() {
	var params_list = Array();

	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
			_offsetY = window.pageYOffset;
			_browser = '';
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.documentElement.clientHeight;
			_offsetY = document.documentElement.scrollTop;
			_browser = 'IE6';
		}
	}

	params_list['winW'] = winW;
	params_list['winH'] = winH;
	params_list['_offsetY'] = _offsetY;
	params_list['browser'] = _browser;

	return 	params_list;

}

var divs = 'center';
var divs_diff = Array( 'top', 'bottom' );

function setHeight() {
	return '';

	params_list = getWindowParams();
	winW = params_list['winW'];
	winH = params_list['winH'];
	_offsetY = params_list['_offsetY'];

	max_h = 0;

	layer = $( divs );
	if ( !layer ) {
		return 0;
	}

	layer2_h = 0;
	for ( sh_i=0; sh_i<divs_diff.length; sh_i++ ) {
		if ( $( divs_diff[sh_i] ) ) {
			layer2_h += $( divs_diff[sh_i] ).offsetHeight;
		}
	}
	if ( ( layer.offsetHeight + layer2_h ) < winH ) {
		layer.style.height = winH - layer2_h+'px';
	}

	layer.style.height = layer.offsetHeight+'px';
}

/* 
CASIO nyitolap animálás
*/

var animate_intv = Array();
function slideOpen( e ) {
	obj = getObj(e).parentNode;
	obj.style.zIndex = 20;
	h = obj.offsetHeight;
	th = 193;
	if ( obj.className.indexOf('height2') != -1 ) {
		th = 165;
	}
	if ( animate_intv[obj.id] ) {
		clearInterval( animate_intv[obj.id] );
	}

	animate_intv[obj.id] = eval( "setInterval( 'animate(\""+obj.id+"\", "+h+", "+th+")', 5 )");

}

function slideClose( e ) {
	obj = getObj(e).parentNode;
	h = obj.offsetHeight;
	if ( animate_intv[obj.id] ) {
		clearInterval( animate_intv[obj.id] );
	}
	animate_intv[obj.id] = eval( "setInterval( 'animate(\""+obj.id+"\", "+h+", 63)', 5 )");

}

function animate( id, from, to ) {
	step = 7;
	obj = $(id);
	obj_a = obj.getElementsByTagName("A")[0];
	if ( from >= to ) {
		if ( obj.offsetHeight <= to ) {
			obj.style.height = to+'px';
			obj_a.style.height = to+'px';
			if ( animate_intv[obj.id] ) {
				clearInterval( animate_intv[obj.id] );
				obj.style.zIndex = 10;
			}
		} else {
			obj_a.style.height = obj_a.offsetHeight-step+'px';
			obj.style.height = obj.offsetHeight-step+'px';
		}
	} else {
		if ( obj.offsetHeight >= to ) {
			obj.style.height = to+'px';
			if ( animate_intv[obj.id] ) {
				clearInterval( animate_intv[obj.id] );
			}
		} else {
			obj.style.height = obj.offsetHeight+step+'px';
		}
		obj_a.style.height = obj.offsetHeight+'px';
	}
}

/* -------------------------------------------------------------------------- */
/* CITIZEN gyorsikonok animálása */

var init_ready = 0;
var left_menu = Array();
var quick_menu = Array();
var active_menu  = Array();

function resetImages(obj) {

	for( image in active_menu ) {
		chg_nrm(active_menu[image]);
	}
	active_menu = Array();
	if ( $('cat_logo') )
		$('cat_logo').src = act_logo;
}

function selectLink( obj ) {
//	alert(obj.href);
	if ( left_menu[obj.href] ) {
		p = left_menu[obj.href].parentNode;
		p.className = p.className+' active_quick'
	}
}

function unSelectLink() {

	for( menu in left_menu ) {
		if ( left_menu[menu].parentNode ) {
			p = left_menu[menu].parentNode;
			p.className = p.className.replace( 'active_quick', '' );
		}
	}

}

function initCitizenQuick() {
	if ( $('leftmenu') && $('oralist') ) {
		tmp = $('oralist').getElementsByTagName("A");
		for( j=0; j < tmp.length; j++ ) {
			link = tmp[j].toString();
			quick_menu[link] = tmp[j];
		}
	}
}

function initCitizenLeftMenu_forQuick() {
	if ( $('leftmenu') ) {
		tmp = $('leftmenu').getElementsByTagName("A");
		for( lm_i=0;lm_i<tmp.length;lm_i++ ) {
			addEvent( tmp[lm_i], 'mouseover', selectQuick );
			addEvent( tmp[lm_i], 'mouseout', resetImages );
			link = tmp[lm_i].toString();
			left_menu[link] = tmp[lm_i];
		}
	}
}

function initImages() {
	if ( $('oralist') ) {
		a = $('oralist').getElementsByTagName("IMG");
		change=0;
		var image_pos=Array;
		for( i=0; i<a.length; i++ ) {
			parent_n = a[i].parentNode;
			parent_n.style.width=parent_n.offsetWidth+'px';
			parent_n.style.height=parent_n.offsetHeight+'px';
		}
		init_ready = 1;
	}
}

function selectQuick( e ) {

	obj = getObj(e)
	if ( obj && obj.nodeName && ( obj.nodeName == 'A' ) ) {
		if ( quick_menu[obj.href] ) {
			chg_big(quick_menu[obj.href].getElementsByTagName("IMG")[0]);
		}

	}
}

function chg_big( obj ) {
	if ( init_ready ) {
		resetImages(obj);
		imgHTML = obj.parentNode.innerHTML.replace( "_k", "_n" );
		imgHTML = imgHTML.replace( 'onmouseover="chg_big(this)"', 'onmouseout="resetImages(this)"' );
		imgHTML = imgHTML.replace( 'onmouseover=chg_big(this)', 'onmouseout="resetImages(this)"' );
		parent_n = obj.parentNode;
		selectLink( parent_n );
		parent_n.innerHTML=imgHTML;
		parent_n.firstChild.className = 'oralista act_ora'
		active_menu[obj.href] = parent_n.firstChild;

		if ( $('cat_logo') ) {
			t = obj.src.split("/");
			n = t[t.length-1].split("_");
			cn_a = Array();
			for( si=1; si<n.length-1; si++ ) {
				cn_a[si-1] = n[si];
			}
			cn = cn_a.join('_');
			$('cat_logo').src = cat_logo[cn];
		}
	}
}

function chg_nrm(obj) {
	if ( obj.parentNode ) {
		imgHTML = obj.parentNode.innerHTML.replace( '_n.', '_k.' );
		imgHTML = imgHTML.replace( 'onmouseout="resetImages(this)"', 'onMouseOver="chg_big(this)"' );
		imgHTML = imgHTML.replace( 'onmouseout=resetImages(this)', 'onMouseOver="chg_big(this)"' );
		parent_n = obj.parentNode;
		parent_n.innerHTML=imgHTML;
		parent_n.firstChild.className = 'oralista normal_ora'
		unSelectLink();
	}
}

/* ------------------------------------------------------------------------- */

function initCitizenLeftMenu() {
	if ( $('leftmenu') ) {
		left_menu_cover = $('leftmenu');
	}
}

function floatMenu() {
	params_list = getWindowParams();
	_offsetY = params_list['_offsetY'];

	topH = $('top').offsetHeight;
	if ( topH - _offsetY <= 0 ) {
		/* MÁR NEM LÁTSZIK A FEJLÉC */
		if ( params_list['browser'] ) {
			left_menu_cover.style.top = _offsetY-topH+'px';
		} else {
			left_menu_cover.style.position = 'fixed';
			left_menu_cover.style.top = -topH+'px';
		}

	} else {
		/* MÉG LÁTSZIK A FEJLÉC */
		left_menu_cover.style.position = 'absolute';
		left_menu_cover.style.top = '0px';
	}
}


function initCitizenRight() {
//	obj = new RotateContent('latest_products_cover', 2 );
}

window.onscroll = scrollEvent;
function scrollEvent() {
	if ( left_menu_cover ) {
		floatMenu();
	}
}

function initBrowser() {
	if ( $('browser_div') ) {
        if ( navigator.appVersion.indexOf('MSIE 7')!=-1 ) {
			$('browser_div').id = 'browser_div_ie7';
		} else {
		}
	}
}

function initSite() {
	if ( $('nyitooldali_table') ) {
		$('mainbody').style.backgroundImage = 'url(sablons/cms/pics/bg.jpg)';
		$('center').style.backgroundColor = '#B0B0B0';
	} else if ( $('szerviz_table') || $('szak_content') ) {
		$('mainbody').style.backgroundImage = 'url(sablons/cms/pics/szerviz_bg.jpg)';
		$('center').style.backgroundColor = '#AEAEAC';
	}

	if ( $('tartalom') && $('szak_kezdo') ) {
		t = $('szak_kezdo');
		szak_megjelen( t, 1);
	}

	if ( $('mainTable') ) {
		$('mainTable').style.width = $('mainLeft').offsetWidth+$('extraBanners').offsetWidth+'px';
	}
}

function initCasioOpen() {
	if ( !$('casio_activ_dial') )
		return 0;

	sdi = 0;
	slide_divs = Array();
	divs1 = document.getElementsByTagName("DIV");
	for( di=0; di < divs1.length; di++ ) {
		if ( divs1[di].className.indexOf('casio_slidebox') != -1 ) {
			addEvent(divs1[di].getElementsByTagName("A")[0], 'mouseover', slideOpen);
			addEvent(divs1[di].getElementsByTagName("A")[0], 'mouseout', slideClose);
			slide_divs[sdi++] = divs1[di];
		}
	}
}


var szak_active = 0;
var szak_obj = null;

function szak_megjelen(obj, uj) {

	if( uj!=szak_active ) {
		szak_active=uj;
		$('tartalom').innerHTML = '<div id="in_tartalom">'+$('szak_menu_' + szak_active).innerHTML+'</div>';
		if ( szak_obj ) {
			ncstr = Array();
			cstr = szak_obj.className.split(' ');
			for( i=0; i<cstr.length-1; i++ ) {
				ncstr[i] = cstr[i];
			}
			szak_obj.className = ncstr.join(' ');
		}
		obj.className = obj.className+' hover';
		szak_obj = obj;

		tartalom_div = $('in_tartalom');
		tartalom_div.id = obj.id;
		addEvent(tartalom_div, 'click', clickSzakSzerviz);

		autoLoadSzak(obj.id);
	}
}

var loadszakT = null;
function autoLoadSzak(link) {
	if ( loadszakT ) clearTimeout(loadszakT);
	loadszakT = setTimeout("showSzakSzerviz('"+link+"')", 1000);
}

function showSzakSzerviz(link) {
	$('new_content').innerHTML = '<p>Kérem várjon...</p>';

	new Ajax.Request( link, {
			method: 'get',
			onSuccess: function(new_c) {
				var tmp_c = document.createElement("DIV");
				tmp_c.innerHTML = new_c.responseText;

				divs = tmp_c.getElementsByTagName('DIV');
				for( k=0; k<divs.length; k++ ) {
					if ( divs[k].className && ( divs[k].className == 'text' ) ) {
						$('new_content').innerHTML = divs[k].innerHTML;
					}
				}
			}
		}
	);
}

function clickSzakSzerviz(e) {

	if (!e) var e = window.event;
	if (e.target) tag = e.target;
	else if (e.srcElement) tag = e.srcElement;
	if (tag.nodeType == 3)
		targ = tag.parentNode;

	while( !tag.id || ( tag.id.indexOf('http') == -1 ) ) {
		if ( !tag.parentNode ) {
			return 0;
		}
		tag = tag.parentNode;
	}

	obj = tag;
	link = obj.id;

	showSzakSzerviz(link);
}

function initSzakSzerviz(start) {

	obj = null;
	if ( $('szak_content') ) {
		obj = $('szak_content');
	} else if ( $('szerviz_content') ) {
		obj = $('szerviz_content');
	}

	if ( !obj ) return false;

	var links_href = Array();

	lis = obj.getElementsByTagName("LI");
	links = Array();
	links_id = Array();
	l_i = 0;
	for( sz_i=0; sz_i<lis.length; sz_i++ ) {
		if ( lis[sz_i].className.indexOf("menu_link") != -1 ) {
			links[l_i++] = lis[sz_i];
			p = lis[sz_i].getElementsByTagName('P');
			if ( p.length ) {
				h = 0
				for( p_i=0; p_i<p.length; p_i++ ) {
					h += p[p_i].offsetHeight;
				}
				if (h) {
					pTop = Math.max(29-(h/2),0);
					p[0].style.paddingTop = pTop+'px';
				}
			}
		}
	}

	for( sz_i=0; sz_i<links.length; sz_i++ ) {
		a_l = links[sz_i].getElementsByTagName("A");
		for( j=0; j<a_l.length; j++ ) {
			links[sz_i].id=a_l[j].href;
			a_l[j].removeAttribute('href');
			addEvent(links[sz_i], 'click', clickSzakSzerviz);
		}

	}
	showSzakSzerviz(links[start].id);
	szak_megjelen( links[start], start+1);
}

var rotateDivs = Array();
var rotateId = Array();
function initRotateProducts(id) {
	if ( !$(id) )
		return 0;

	j = 0;
	divs = Array();
	divsTmp = $(id).getElementsByTagName("DIV");
	for(i=0;i<divsTmp.length;i++)
		if (divsTmp[i].className == 'webshop_product')
			divs[j++] = divsTmp[i];

	if ( divs.length <= 2 )
		return 0;
	rId = rotateDivs.length;
	rotateDivs[rId] = divs;
	rotateId[rId] = 0;
}

function rotateProducts() {
	for(i=0;i<rotateDivs.length;i++) {
		divs = rotateDivs[i];
		actId = rotateId[i];
		nextId = (actId >= (divs.length/2-1)) ? 0 : actId+1;

		divs[nextId*2].style.display = 'block';
		if ( divs[nextId*2+1] )
			divs[nextId*2+1].style.display = 'block';

		divs[actId*2].style.display = 'none';
		if ( divs[actId*2+1] )
			divs[actId*2+1].style.display = 'none';

		rotateId[i] = nextId;
	}
	setTimeout( 'rotateProducts()', 3000 );
}

var left_menu_cover = null;

function startPageScripts() {
	initSite();
	initCitizenQuick();
	initImages();
	initCitizenLeftMenu_forQuick();
	initCitizenLeftMenu();
//	initCitizenRight();
	initCasioOpen();
	initRotateProducts('latest_product_cover');
	initRotateProducts('random_product_cover');
//	setTimeout( 'rotateProducts()', 3000 );
	rot0 = new SlideDivs('rCUjdonsag0', 'webshop_product', 4000);
	rot1 = new SlideDivs('rCUjdonsag1', 'webshop_product', 5000);
	rot2 = new SlideDivs('rCAkcio0', 'webshop_product', 4000);
	rot3 = new SlideDivs('rCAkcio1', 'webshop_product', 5000);
}

addEvent(window, 'load', startPageScripts);
/*
addEvent(window, 'load', initSite);
addEvent(window, 'load', initCitizenQuick);
addEvent(window, 'load', initImages);
addEvent(window, 'load', initCitizenLeftMenu_forQuick);
addEvent(window, 'load', initCitizenLeftMenu);
addEvent(window, 'load', initCitizenRight);
addEvent(window, 'load', initCasioOpen);
*/
//addEvent(window, 'load', initSzakSzerviz);


/* Anita */

function generateDays() {
	var y = document.getElementById("year");
	var m = document.getElementById("month");
	var year = y.options[y.selectedIndex].value;
	var month = m.options[m.selectedIndex].value;
	var d = new Date();
	d.setFullYear(year, month-1, 28);
	var index=28;
	while (d.getMonth() == month-1) {
		index++;
		d.setFullYear(year, month-1, index);
	} 
	day = document.getElementById("day");
	while (day.options.length > 28) {
		day.removeChild(day.lastChild);
	}
	var val;
	for (i=28;i<index-1;i++) {
		val = (i+1);
		day.options[i] = new Option(val, val);
	}
}

function checkForm(f) {
	var e;
	for (i=0;i<f.elements.length;i++) {
		e = f.elements[i];
		if (e.value == ""  && (e.name != "bill" && e.name !="receipt") ) {
			alert("Minden adat megadása kötelező!");
			return false;
		}
	}
}

function httpGet(url, callback) {
	new Ajax.Request( url, {
		method: 'get',
		onSuccess: function(wr) {
			callback(wr);
		}
	});
}

/* REGI RENDELESEK MEGJELENITESE */

function getOrder(id) {
	if ($(''+id).firstChild != null) closeDiv(id);
	else {
		var url = "?l1=webstore&l2=plug_webstore_order&l3=main&type=info&id=" + id;
		$('text_'+id).innerHTML = 'Betöltés folyamatban';
		httpGet(url, cb);
	}
}

function cb(wr) {
	var locdiv;
	var obj = eval('('+wr.responseText+')');
	var div = document.getElementById(obj.id);

	$('text_'+obj.id).innerHTML = '';
	div.style.display = "block";
	newdiv = document.createElement("div");
	locdiv = div.appendChild(newdiv);
	locdiv.className = "close";
	locdiv.innerHTML = '<img src="sablons/cms/pics/close_.jpg" onclick="closeDiv('+obj.id+')" />';
	for (var i in obj) {
		if (i != "id") {
			if (i == "table0") {
				newdiv = document.createElement("div");
				locdiv = div.appendChild(newdiv);
				locdiv.className = "t_header";
				locdiv.innerHTML = '<table><tr><td class="long">Termék</td><td>Mennyiség</td><td>Egységár</td><td>Kézbesített</td><td>Fennmaradó</td><td>Törölt</td><td>Ár</td></tr></table>';
			}
			newdiv = document.createElement("div");
			locdiv = div.appendChild(newdiv);
			locdiv.className = i;
			locdiv.innerHTML = obj[i];
		}
	}
		var r = document.getElementById("right");
	var c = document.getElementById("center");
	var o = document.getElementById("main_order_cont");
	r.style.height = c.style.height = (o.offsetHeight > r.offsetHeight)?o.offsetHeight+'px':r.offsetHeight+'px';
}

function closeDiv(id) {
	var div = document.getElementById(id);
	while (child = div.firstChild) {
		div.removeChild(child);
	}
	div.style.display = "none";
}

function forground(obj, bool) {
	var z = (navigator.appName=="Netscape")?Number(obj.style.zIndex):obj.currentStyle.zIndex;
	z += (bool)?35:-35;
	obj.style.zIndex = z;
}

function orderingRule(col, rule) {
	var url = "?l1=webstore&l2=plug_webstore_order&l3=main&type=info&col="+col+"&rule="+rule;
	httpGet(url, order);
}

function order(wr) {
	var obj = eval('('+wr.responseText+')');
	var elems = document.getElementById("ord_cont");
	var index = 0; 
	for (var i=0;i<elems.childNodes.length;i++) {
		if (elems.childNodes[i].nodeType != 3) {
			if (index > 0) {
				t = 'elem'+(index-1);
				elems.childNodes[i].innerHTML = obj[t];
			}
			index++;
		}
	}
}

/* SEARCHBOX SUBMIT */

function checkLength(f) {
	if (f.search_word.value.length < 3) {
		return false;
	} else return true;
}

function setopacity(o, b) {
	o.className = (b)?"button_hover":"";
}

function showWelcome() {
	document.getElementById("rem").parentNode.removeChild(document.getElementById("rem"));
	window.clearTimeout(tid);
}


/* rotateImages obj */
function SlideDivs(id, subClassName, waitT) {
	var me = this;
	this.mainDiv = null;
	this.subDivs = Array();
	this.subDivId = 0;
	this.subDivWidth = 0;
	this.leftPos = 0;
	this.relPos = 0;
	this.step = 2.5;
	this.speed = 10;
	this.wait = 3000;
	this.timer;

	function slideNextDiv() {
		if ( !me.subDivWidth ) {
			me.subDivWidth = me.subDivs[me.subDivId].offsetWidth;
		}
		me.relPos += me.step;
		me.leftPos -= me.step;
		if ( me.relPos > me.subDivWidth ) {
			//Mozgatás vége, helyes poziccióba helyezés a léptetésből adódó különbség miatt
			me.leftPos -= (me.subDivWidth - me.relPos);
			me.subDivWidth = me.relPos = 0;
			me.subDivId += 1;
			clearInterval(me.timer);
			if ( me.subDivId == me.subDivs.length ) {
				me.leftPos = 0;
				me.subDivId = 0;
			}
			setTimeout(run, me.wait);
		}
		me.mainDiv.style.left = me.leftPos+'px';
	}

	this.initDivs = function() {
		if (!$(id)) return 0;
		this.mainDiv = $(id);
		this.wait = waitT;
		mainWidth = 0;
		subDivsT = this.mainDiv.getElementsByTagName('DIV');
		j=0;
		for(i=0;i<subDivsT.length;i++) {
			if (subDivsT[i].className == subClassName) {
				this.subDivs[j++] = subDivsT[i];
				mainWidth += subDivsT[i].offsetWidth;
			}
		}
		this.mainDiv.appendChild(this.subDivs[0].cloneNode(true));
		this.mainDiv.style.width = mainWidth+this.subDivs[0].offsetWidth+'px';
		setTimeout(run, this.wait);
	}

	function run() {
		if ( me.subDivs.length > 1 )
			me.timer = setInterval(slideNextDiv, me.speed);
	}

	this.initDivs(id, subClassName, waitT);
}

function sendFromData() {
	retText = '&time='+ new Date().getTime();
	$j.post(
		$j(this)[0].action+retText,
		$j(this).serialize(),
		function(responseText) {
			oText = responseText;
			if ( responseText == 'sent' ) {
				$j('.megsegomb').click();
				oText = "Köszönjük tájékoztatását!\nHamarosan válaszolunk.";
			}
			alert(oText);
		}
	);

	return false;
}

function scrollToTag(id) {
	screenTop = $j(window).scrollTop();
	tagPos = $j("#"+id).offset().top;
	if ( tagPos-screenTop < 100 ) {
	} else if ( tagPos-screenTop > 500 ) {
		$j(window).scrollTop(tagPos-screenTop-300);
	}
}

$j(document).ready(function() {
	$j('.ajandekImg').hover(
		function() {
			$j(this).siblings('.ajandekDesc').fadeIn();
		},
		function() {
			$j(this).siblings('.ajandekDesc').fadeOut();
		}
	);

	$j(".gomb").html(function() {
		$j(this).css('position', 'relative');
		return '<span class="gombl"></span><span class="gombc">'+$j(this).html()+'</span><span class="gombr"></span>';
	});

	$j(".jForm").bind("submit", sendFromData );
	
	$j('#kuponid').keyup(function() {
		if ($j(this).val()) {
			$j('#kuponbtn').show();
		} else {
			$j('#kuponbtn').hide();
		}
	});
	$j('#kuponbtn').click(function() {
		$j.get(
			'http://www.timecenter.hu/?l1=webstore&l2=plug_webstore&l3=main&checkkupon='+$j('#kuponid').val(),
			function(ret) {
				if ( ret ) { goTo('http://www.timecenter.hu/?l1=webstore&l2=plug_webstore_cart&l3=main'); }
				else { alert('Az Ön által megadott Kuponkód nem érvényes!') }
			} 
		)
	});
});

