function detectBrowser()
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var curver=b_version.split(";");
var cv=curver[1].split(" ");
cve=parseInt(cv[2]);
//alert(cve);
}

function valt(objid, mive, dur) {
start=0;

new Effect.Morph(objid, {style: mive, duration: dur, queue:{position: 'end', scope: 'mscope', limit: 200 }});
}
function valtc(objid, mive, dur) {
/*var queue = Effect.Queues.get('rscope');
						queue.each( function(effect) { effect.cancel(); });*/
new Effect.Morph( 
		objid, 
		{
			style: mive, 
			duration: dur, 
			queue:
			{
				position: 'end', 
				scope: 'rscope', 
				limit: 2
			}
		}
	);
}
function valtb(objid, mive, dur) {
start=0;
//curxy=$('tmhover').cumulativeOffset();
xy=$(objid).cumulativeOffset();
var dim = $(objid).getDimensions();
bxy=$('prod_list').cumulativeOffset();
var bdim = $('prod_list').getDimensions();
var queue = Effect.Queues.get('prodl');
queue.each( function(effect) { effect.cancel(); });
check=$('tmhover').getStyle('display');
if (check=='none') { $('tmhover').setStyle({'top': parseInt(xy[1])+'px', 'left': parseInt(xy[0])+'px', 'display': 'block'}); }
$('pretmhover').setStyle({'top': parseInt(bxy[1])+'px', 'left': parseInt(bxy[0])+'px', 'display': 'block'}); 
//new Effect.Morph('tmhover', {style:'width: '+dim.width+'px; height: '+dim.height+'px; top: '+parseInt(xy[1])+'px; left: '+xy[0]+'px;'  , queue:{position: 'end', scope: 'checkbox', limit: 100 }, duration: 0.2}   );
	new Effect.Morph('tmhover', {style:'width: '+dim.width+'px; height: '+dim.height+'px; top: '+parseInt(xy[1])+'px; left: '+xy[0]+'px;'  , queue:{position: 'end', scope: 'prodl', limit: 2 }, duration: 0.3, afterFinish: function () { $('pretmhover').hide(); if ($F('curprodid')!==objid) {$('curprodid').value=objid;} }}    );
/* $('tmhover').setStyle( 
	{
		'width':  dim.width+'px', 
		'height': dim.height+'px', 
		'top': parseInt(xy[1])+'px', 
		'left': parseInt(xy[0])+'px'
	}
);
$('tmtable').setStyle( 
	{
		'width':  dim.width+'px', 
		'height': dim.height+'px' 
		
	}
);
if ($F('curprodid')!==objid) {$('curprodid').value=objid; } */
new Effect.Morph('tmtable', {style:'width: '+dim.width+'px; height: '+dim.height+'px; top: '+parseInt(xy[1])+'px; left: '+xy[0]+'px;'  , queue:{position: 'end', scope: 'prodl', limit: 2 }, duration: 0.1}  );


//$('pageloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px'});
//new Effect.Morph(objid, {style: mive, duration: dur});
}
function loadlist(objid){
	xy=$(objid).cumulativeOffset();
	var dim = $(objid).getDimensions();
	$('pageloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'top': parseInt(xy[1])+'px', 'left': parseInt(xy[0])+'px', 'display': 'block'});
	new Ajax.Updater(
		$('workcont'),
		'content_prodlist.php',{
			method: 'post',
			parameters: $('kereso').serialize(),
			onComplete: function() {
				var newcont=document.getElementById('workcont').innerHTML;
				document.getElementById('workcont').innerHTML='&nbsp;';
				document.getElementById(objid).innerHTML=newcont;
				$('pageloader').hide();
				
			}
		}
	);
}
function getOpacity(objid)
{
  var opacity = null;
  var browser=navigator.appName;
  var element=document.getElementById(objid);
  //Get the opacity based on the current browser used
  if(browser=="Microsoft Internet Explorer") {
    filter = element.style.filter;
    if(filter) {
      alpha = filter.split("alpha(opacity=");
      opacity = alpha[1].substr(0,(alpha[1].length-1))/100;
    }
  }
  else {
    opacity = element.style.opacity;
  }
    
  return opacity;
}
function fadeon(objid, dur) {

new Effect.Parallel([
										new Effect.Opacity(objid, { from: 0, to: 1.0, duration: dur})
									],  {duration: dur, queue:{position: 'end', scope: 'checkbox', limit: 200 }});
}	
function fadeoff(objid, dur) {
new Effect.Parallel([
										new Effect.Opacity(objid, { from: 1.0, to: 0, duration: dur})
									],  {duration: dur, queue:{position: 'end', scope: 'checkbox', limit: 200 }});
}	

function initcont(mode) {
check=$('main_cont').getStyle('display');
if (check=='none') {  $('hirekcont').update('');  $('hirekcont').innerHTML; $('main_cont').show(); }
new Ajax.Updater(
	$('kp_cont'),
	'content_keresopanel.php',
	{
		method: 'post',
		parameters: { 'mode': mode },
		onCreate: function() {									
				$('searchloader').show();	
		},
	    onComplete: function() {
									
				$('searchloader').hide();
				$('kp_cont').show();
												
								new Ajax.Updater(
									$('includecont'),
									'content_prodlist.php',{
										method: 'post',
										parameters: $('kereso').serialize(),
										onCreate: function() {									
														$('mainloader').show();	
										},
										onComplete: function() {
											$('mainloader').hide();														
											$('includecont').show();
											new Ajax.Updater(
													$('hirekcont'),
													'content_hirek.php',{
														method: 'post',
														parameters:  { 'mode': mode },
														onCreate: function() {									
																		$('hirloader').show();	
														},
														onComplete: function() {
															$('hirloader').hide();														
															$('hirekcont').show();
															openw('registration_activate.php', 'activater',' ');
														}
													}
												);
										}
									}
								);
									}	
	});
}
function loadw(){
var objid='fullkeret';
/*xy=$(objid).cumulativeOffset();
				var dim = $(objid).getDimensions();
				$('windowloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'display': 'block'});
				myLightWindow.activateWindow (
				{
					href: '#mywincontainer', 
					resizeSpeed : 20,
					width: 510,
					height: 400,
					type: 'inline',
					title: ''
				}
				);*/
new Ajax.Updater(
		$('mywincontainer'),
		'showproduct.php',
		{
			method: 'post',
			parameters:  
			{
				'curprodid': $('curprodid').value
			},
			onComplete: function() 
			{
				xy=$(objid).cumulativeOffset();
				var dim = $(objid).getDimensions();
				var wc = $('mywincontainer').getDimensions();
				var ww=parseInt(wc.width+30);
				var wh=parseInt(wc.height+30);
				$('windowloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'display': 'block'});
				myLightWindow.activateWindow (
				{
					href: '#mywincontainer', 
					resizeSpeed : 5,
					width: ww,
					height: wh,
					type: 'inline',
					title: ''
				}
				);
			}
		}
);

}
function refresh_cart(){

new Ajax.Updater(
					$('cartitemcont'),
					'content_cart.php',{
						method: 'post',
						parameters: $('cartitemcontform').serialize(),
						onCreate: function() {									
							//$('cartitemcont').hide();			
							//$('cartloader').show();	
						},
						onComplete: function() {
						//	$('cartloader').hide();														
						//	$('cartitemcont').show();
							$('cart_sum').update($F('vegossz'));
							$('cart_sum').innerHTML;
						}
					}
				);
}
function addtocart(uid,amount){



$('newprep_id').value=uid;
$('newprep_amount').value=amount;
refresh_cart();
$('newprep_id').value='';
$('newprep_amount').value='';
//alert(" A Termék sikeresen bekerült a kosárba.");
myLightWindow.deactivate(); $('windowloader').hide();

}
function refresh_search() {
$('tmhover').hide(); 
xy=$('includecont').cumulativeOffset();
	var dim = $('includecont').getDimensions();
	$('pageloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'top': parseInt(xy[1])+'px', 'left': parseInt(xy[0])+'px', 'display': 'block'});
new Ajax.Updater(
				$('workcont'),
				'content_prodlist.php',{
					method: 'post',
					parameters: $('kereso').serialize(),
					onCreate: function() {									
									$('pageloader').show();	
					},
					onComplete: function() {
																			
						
	var newcont=document.getElementById('workcont').innerHTML;
				document.getElementById('workcont').innerHTML='&nbsp;';
				document.getElementById('includecont').innerHTML=newcont;
				$('pageloader').hide();
$('includecont').show();
					}
				}
				);
}

function openw(what, form, cim){

new Ajax.Updater(
		$('mywincontainer'),
		what,
		{
			method: 'post',
			parameters:  $(form).serialize(),
			onComplete: function() 
			{
					
				xy=$('fullkeret').cumulativeOffset();
				var dim = $('fullkeret').getDimensions();
				var wc = $('mywincontainer').getDimensions();
				var ww=parseInt(wc.width);
				var wh=parseInt(wc.height);
				if (wh > 450 ) { wh=450; }
				$('windowloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'display': 'block'});
				myLightWindow.activateWindow (
				{
					href: '#mywincontainer', 
					resizeSpeed : 80,
					width: ww,
					height: wh,
					type: 'inline',
					title: ''+cim
				}
				);
				$('mywincontainer').innerHTML='&nbsp;';
			if (what=='content_registration.php' || what=='content_registration_mod.php' ) 
					{
						$('regscroll').setStyle({'overflow': 'auto'});
						 var name = new LiveValidation( 'name' );
							name.add( Validate.Presence);
							name.add( Validate.Length,  {minimum: 6, maximum: 300} );
					var email = new LiveValidation('email');
							email.add( Validate.Presence);
							email.add( Validate.Email );
					   var  password = new LiveValidation('password');	
							password.add( Validate.Presence);				    
							password.add( Validate.Confirmation, { match: 'repassword' } );
	var  repassword = new LiveValidation('repassword');	
							repassword.add( Validate.Presence);				    
							repassword.add( Validate.Confirmation, { match: 'password' } );
						var ert_irsz = new LiveValidation('ert_irsz');	
							ert_irsz.add( Validate.Presence);
							ert_irsz.add( Validate.Numericality, { onlyInteger: true } );
							ert_irsz.add( Validate.Length, { is: 4 } );
						var ert_varos = new LiveValidation('ert_varos');	
							ert_varos.add( Validate.Presence);
						var ert_utca = new LiveValidation('ert_utca');	
							ert_utca.add( Validate.Presence);
						var szall_irsz = new LiveValidation('szall_irsz');	
							
							szall_irsz.add( Validate.Numericality, { onlyInteger: true } );
							szall_irsz.add( Validate.Length, { is: 4 } );
						var keystring = new LiveValidation("keystring");
							keystring.add( Validate.Presence );
							keystring.add( Validate.Numericality, { onlyInteger: true } );
							keystring.add( Validate.Length, { is: 4 } );
					} 
			}
		}
);

}
function ajaxupdate(where, what, form) {
	new Ajax.Updater(
			$(where),
			what,
			{
				method: 'post',
				parameters:  $(form).serialize()
				
			}
	);
}
function checkreg(){
	 var name = new LiveValidation( 'name' );
							name.add( Validate.Presence);
							name.add( Validate.Length,  {minimum: 6, maximum: 300} );
					var email = new LiveValidation('email');
							email.add( Validate.Presence);
							email.add( Validate.Email );
					   var  password = new LiveValidation('password');	
							password.add( Validate.Presence);				    
							password.add( Validate.Confirmation, { match: 'repassword' } );
 						var  repassword = new LiveValidation('repassword');	
							repassword.add( Validate.Presence);				    
							repassword.add( Validate.Confirmation, { match: 'password' } );
						var ert_irsz = new LiveValidation('ert_irsz');	
							ert_irsz.add( Validate.Presence);
							ert_irsz.add( Validate.Numericality, { onlyInteger: true } );
							ert_irsz.add( Validate.Length, { is: 4 } );
						var ert_varos = new LiveValidation('ert_varos');	
							ert_varos.add( Validate.Presence);
						var ert_utca = new LiveValidation('ert_utca');	
							ert_utca.add( Validate.Presence);
						var szall_irsz = new LiveValidation('szall_irsz');	
							
							szall_irsz.add( Validate.Numericality, { onlyInteger: true } );
							szall_irsz.add( Validate.Length, { is: 4 } );
						var keystring = new LiveValidation("keystring");
							keystring.add( Validate.Presence );
							keystring.add( Validate.Numericality, { onlyInteger: true } );
							keystring.add( Validate.Length, { is: 4 } );
var areAllValid = LiveValidation.massValidate( [name, email, password, ert_irsz, ert_varos, ert_utca, szall_irsz, keystring] );
//areAllValid = LiveValidation.massValidate( ['name', 'email', 'password', 'ert_irsz', 'ert_varos', 'ert_utca', 'szall_irsz', 'keystring'] );
if (areAllValid) {  document.reg.submit(); }
//else { alert("Nincs megfelelően kitöltve"); }
}
function checkregmod(){
	 var name = new LiveValidation( 'name' );
							name.add( Validate.Presence);
							name.add( Validate.Length,  {minimum: 6, maximum: 300} );
					var email = new LiveValidation('email');
							email.add( Validate.Presence);
							email.add( Validate.Email );
					   var  password = new LiveValidation('password');	
							password.add( Validate.Presence);				    
							password.add( Validate.Confirmation, { match: 'repassword' } );
						var ert_irsz = new LiveValidation('ert_irsz');	
							ert_irsz.add( Validate.Presence);
							ert_irsz.add( Validate.Numericality, { onlyInteger: true } );
							ert_irsz.add( Validate.Length, { is: 4 } );
						var ert_varos = new LiveValidation('ert_varos');	
							ert_varos.add( Validate.Presence);
						var ert_utca = new LiveValidation('ert_utca');	
							ert_utca.add( Validate.Presence);
						var szall_irsz = new LiveValidation('szall_irsz');	
							
							szall_irsz.add( Validate.Numericality, { onlyInteger: true } );
							szall_irsz.add( Validate.Length, { is: 4 } );
						var keystring = new LiveValidation("keystring");
							keystring.add( Validate.Presence );
							keystring.add( Validate.Numericality, { onlyInteger: true } );
							keystring.add( Validate.Length, { is: 4 } );
var areAllValid = LiveValidation.massValidate( [name, email, password, ert_irsz, ert_varos, ert_utca, szall_irsz, keystring] );
//areAllValid = LiveValidation.massValidate( ['name', 'email', 'password', 'ert_irsz', 'ert_varos', 'ert_utca', 'szall_irsz', 'keystring'] );
if (areAllValid) {   document.reg.submit();  }
//else { alert("Nincs megfelelően kitöltve"); }
}
function select_change(objid,what) {
$(objid).value=what;
check=$('main_cont').getStyle('display');
if (check=='none') {   $('main_cont').show();  }
refresh_search();
new Ajax.Updater(
		$('hirekcont'),
		'content_hirek.php',{
			method: 'post',
			parameters:  { 'mode': '0' },
			onCreate: function() {									
							$('hirloader').show();	
						} ,
			onComplete: function() {
								$('hirloader').hide();
															
							}
			}
	);
}
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 
function showhir(hirid){
$('tmhover').hide();
xy=$('hirekcont').cumulativeOffset();
	var dim = $('hirekcont').getDimensions();
	$('pageloader').setStyle({'width':  dim.width+'px', 'height': dim.height+'px', 'top': parseInt(xy[1])+'px', 'left': parseInt(xy[0])+'px', 'display': 'block'});
	$('pageloader').show();
	new Effect.ScrollTo('fullkeret', {  duration: 1.0, afterFinish: function() {
	
			new Ajax.Updater(
						$('hirekcont'),
						'content_hir.php',{
							method: 'post',
							parameters: {'hirid' : hirid},
							onCreate: function() {									
								
								$('main_cont').hide();	
								
							},
							onComplete: function() {
								$('pageloader').hide();
															
							}
						}
			);
	}});	
	}
function kedvenchez(uniqueid,prodid) {
new Ajax.Updater(
						$('fav_cont'),
						'kedvencek.php',{
							method: 'post',
							parameters: {'uniqueid' : uniqueid, 'prodid': prodid}
							
						}
			);
}
function delfav(uniqueid,prodid) {
new Ajax.Updater(
						$('product_del'),
						'kedvencek_del.php',{
							method: 'post',
							parameters: {'uniqueid' : uniqueid, 'prodid': prodid},
							onComplete: function() {
									$('product'+prodid).remove();
							}
							
						}
			);
}
