
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);

/// Browser detect

var browserType = navigator.appName

if (browserType == 'Microsoft Internet Explorer'){
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
}else if(browserType == 'Netscape'){
    var ua = navigator.userAgent;
    var re  = new RegExp("Firefox/([0-9]\.[0-9]{1,2})\.[0-9]{1,4}");
    
    if (re.exec(ua) != null){rv = RegExp.$1;}
	browserType = 'Firefox';
}else{
	browserType = 'none';
	rv = 0
}
 
var browserVersion = rv;


//// lightbox
var img;
var lightboxOpen = false
var lightboxTitle

function showLightbox(imgurl, title){
	lightboxTitle = title;
	if(!lightboxOpen){
		showLoader()
		lightboxOpen = true
		img = document.createElement('img'); 
		img.id = 'lightboxloadimage'; 
		Event.observe(img, 'load', function(e){addToLightbox(e);},false); 
		//$('lightboxpica').appendChild(img); 
		img.src = imgurl; 
	}
}

function showLoader(){
	var scrollOffsets = document.viewport.getScrollOffsets();
	$('mylightbox').style.display = 'block';
	$('lightboxinfo').style.display = 'none';
	$('lightboxcontainer').style.width = '24px';
	$('lightboxcontainer').style.height = '24px';
	$('lightboxtable_centtd').style.width = '24px';
	$('lightboxtable_centtd').style.height = '24px';
	$('mylightbox').style.width = '90px';
	$('mylightbox').style.height = '60px';
	$('mylightbox').style.left = ((document.viewport.getWidth()/2)) + 'px';
	$('mylightbox').style.top = ((document.viewport.getHeight()/2) + scrollOffsets[1]) + 'px';
}

function closelightbox(){
	$('lightboxpica').innerHTML = '';
	$('mylightbox').fade({duration:0.2, afterFinish: function(){lightboxClosed()}})
	lightboxOpen = false
}

function lightboxClosed(){
	var scrollOffsets = document.viewport.getScrollOffsets();
	$('mylightbox').style.display = 'none';
	$('lightboxpica').innerHTML = '';
	$('lightboxtext').innerHTML ='';
	$('lightboxcontainer').style.width = '56px';
	$('lightboxcontainer').style.height = '56px';
	$('lightboxtable_centtd').style.width = '56px';
	$('lightboxtable_centtd').style.height = '56px';
	$('mylightbox').style.width = '56px';
	$('mylightbox').style.height = '56px';
	$('mylightbox').style.left = ((document.viewport.getWidth()/2)) + 'px';
	$('mylightbox').style.top = ((document.viewport.getHeight()/2) + scrollOffsets[1]) + 'px';
}

function addToLightbox(e){
	
	$('lightboxpica').innerHTML = '';
	$('lightboxpica').appendChild(img);
	$('lightboxtext').innerHTML ='';
	$('lightboxtext').innerHTML = lightboxTitle
	var padding = 56
	var myDuration = 0.3
	var myTransition = Effect.Transitions.sinoidal
	
	Event.stop(e);
	var scrollOffsets = document.viewport.getScrollOffsets();
	
	$('lightboxinfo').style.display = 'none';
	$('mylightbox').style.visibility = 'hidden';
	$('mylightbox').style.display = 'block';
	
	
	$('lightboxcontainer').morph('width:'+img.getWidth()+'px; height:'+img.getHeight()+'px;', {duration:myDuration, transition: myTransition})
	$('lightboxtable_centtd').morph('width:'+(img.getWidth())+'px; height:'+((img.getHeight()))+'px;', {duration:myDuration, transition: myTransition})
	$('mylightbox').morph('width:'+(img.getWidth() + padding)+'px; height:'+((img.getHeight() + padding))+'px;', {duration:myDuration, transition: myTransition})
	$('mylightbox').style.left = ((document.viewport.getWidth()/2)) + 'px';
	$('mylightbox').style.top = ((document.viewport.getHeight()/2) + scrollOffsets[1]) + 'px';
	
	new Effect.Move('mylightbox', { x: ((document.viewport.getWidth()/2)-((img.getWidth() + padding)/2)), y: (((document.viewport.getHeight()/2)-((img.getHeight() + padding)/2)) + scrollOffsets[1]), mode: 'absolute', transition: myTransition, duration:myDuration, afterFinish: function(){fadePictureIn()}});
	
	
	
	$('lightboxcontainer').style.display = 'none';
	$('mylightbox').style.visibility = 'visible';
	lightboxTitle = ''
}

function fadePictureIn(){
	$('lightboxcontainer').appear({duration: 0.3, afterFinish: function(){showLightInfo()}})
}

function showLightInfo(){
	Effect.SlideDown('lightboxinfo', { duration: 0.2 });
}

function alertposition(obj){
	$(obj).style.top = ((document.viewport.getHeight()/2) - ($(obj).offsetHeight/2)) + 'px';
	$(obj).style.left = ((document.viewport.getWidth()/2) - ($(obj).offsetWidth/2)) + 'px';
}

function showAlert(cim, szoveg, gomb){
	$('ajaxmessage').style.display = 'block';
	$('ajaxalerttext').innerHTML = '<h3>'+cim+'</h3>'+szoveg;
	$('alertokbutt').innerHTML = gomb;
	
	
	alertposition('ajaxmessage');
}

// DP
function search_cse() {
	window.open('http://www.google.com/cse?cx=007337298685480077185%3Av4c0ckq9yzg&ie=UTF-8&q=' + q + '&sa=Keres%C3%A9s');
	document.getElementById('alertgodiv').style.display = 'none';
	closemessage();
}

function dp_hide(what) {
	$(document.getElementById(what)).hide();
}

function dp_show(what) {
	$(document.getElementById(what)).show();
}

function checkEmail(a){
	var inputvalue = document.getElementById('email_address').value;
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if(a.email_ertesites[0].checked) {
		if(pattern.test(inputvalue)){
			return true;
		}else{
			showAlert('Hibás adat!', 'Az értesítési e-mail cím nem megfelelő!', 'Ja, elbasztam!');
			document.getElementById('alertgodiv').style.display = 'none';
			return false;
		}
	}
}

function showAlert2(cim, szoveg, gomb, gomb2){
	$('ajaxmessage').style.display = 'block';
	$('ajaxalerttext').innerHTML = '<h3>'+cim+'</h3>'+szoveg;
	$('alertokbutt').innerHTML = gomb;
	document.getElementById('alertgodiv').style.display = 'block';
	document.getElementById('alertgodiv').innerHTML = '<span class="buttspan"><a onclick="elmulttizennyolc(); return false;" href="javascript:void(0);" id="alertgobutt">' + gomb2 + '</a></span>';
	
	
	alertposition('ajaxmessage');
}

function elmulttizennyolc() {
	new Ajax.Request('/modules/elmult.php', {
		method: 'get',
		parameters: {elmult: 'true'}
	  });

	$('ajaxmessage').style.display = 'none';
	try{extclosemessage()}catch(err){}
}
// /DP

function closemessage(){
	$('ajaxmessage').style.display = 'none';
	try{extclosemessage()}catch(err){}
	
	if(dp_mode == "18+") {
		location.href = "/";
	}
}

