function ablak(file,scroll,width,height,name) {
    nagyablak =window.open('',name,'top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=0,width='+width+',height='+height);
    nagyablak.document.open();
    nagyablak.document.write("<html><head><title>Popup</title><LINK rel=\"stylesheet\" href=\"themes/style_common.css\" type=\"text/css\"></head><body bgcolor=#ffffff leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
    nagyablak.document.write("<div align=center><a href='javascript:window.close()'><img src='"+file+"' border='1' alt='"+name+"' class=\"pic\"></a></div>");
    nagyablak.document.write("</body></html>");
    nagyablak.document.close();
} 

function pic_window(url,scroll,width,height){
	if (url != '') {
		window.open(url,'','scrollbars='+scroll+',width='+width+',height='+height+',top=0,left=0');
	}
}

function user_window(url,scroll,width,height){
	if (url != '') {
		window.open(url,'','scrollbars='+scroll+',width='+width+',height='+height+',top=0,left=0');
	}
}

function images_window(url){
	if (url != '') {
		window.open(url,'','scrollbars=0,width=730,height=640,top=0,left=0');
	}
}

function images_window2(url){
	if (url != '') {
		window.open(url,'','scrollbars=1,resizable=1,width=1020,height=640,top=0,left=0');
	}
}

function print_window(url){
	if (url != '') {
		window.open(url,'','scrollbars=1,width=810,height=600,top=0,left=0');
	}
}

function email_window(url){
	if (url != '') {
		window.open(url,'','scrollbars=0,width=575,height=380,top=0,left=0');
	}
}

function check_email_form(eform){
    var hiba = "";

    if (eform.to_email.value == "") hiba = hiba + "Kérjük adja meg a címzett E-mail címét!\n";
    if (eform.from_name.value == "") hiba = hiba + "Kérjük adja meg az Ön nevét!\n";
    
    if (hiba != ""){
		alert(hiba);
		return false;
    }
        
    if (eform.to_name.value == "") hiba = hiba + "A címzett neve\n";
    if (eform.from_email.value == "") hiba = hiba + "Az Ön e-mail címe\n";
    if (eform.message.value == "") hiba = hiba + "Üzenet szövege\n";
    if (hiba != ""){
		if (confirm("A következő mezők nem lettek kitöltve:\n\n"+ hiba + "\nBiztos, hogy elküldi?")){
		    eform.submit();
		    return true;
		}else{
		    return false;
		}    
    }else{
		eform.submit();
		return true;
    }
}

function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  //strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1){
      return false;
    }
    return true;
}

function check_login_form(){
    var hiba = '';
	var eform = document.login_form;

    if (eform.uname.value == '') hiba = hiba + "Kérjük adja meg a felhasználónevet!\n";
    if (eform.upass.value == '') hiba = hiba + "Kérjük adja meg a jelszót!\n";

    if (hiba != ''){
		alert(hiba);
		return false;
    }else{
		eform.submit();
		return true;
    }
}

function check_reg_form(){
    var hiba = '';
	var eform = document.reg_form;

    if (eform.name.value == '') hiba = hiba + "Kérjük adja meg a teljes nevét!\n";
    if (eform.username.value == '') hiba = hiba + "Kérjük adja meg a felhasználónevet!\n";
    if (eform.email.value == '') hiba = hiba + "Kérjük adja meg az email címét!\n";
    if (!isValidEmail(eform.email.value)) hiba = hiba + "Email cím formátuma nem megfelelő!\n";
    if (eform.userpass1.value == '') hiba = hiba + "Kérjük adja meg a jelszót!\n";
	if (eform.userpass2.value == '') hiba = hiba + "Kérjük adja meg a jelszó megerősítést!\n";

    if (hiba != ''){
		alert(hiba);
		return false;
    }else{
		eform.submit();
		return true;
    }
}

function switchHelp(object) {
	if (document.getElementById) {
		if (!document.getElementById(object).style.display){
			document.getElementById(object).style.display = 'block';
			document.getElementById(object).style.visibility = 'visible';			
		}else if (document.getElementById(object).style.display == 'none'){
			document.getElementById(object).style.display = 'block';
			document.getElementById(object).style.visibility = 'visible';
		}else{
			document.getElementById(object).style.display = 'none';
			document.getElementById(object).style.visibility = 'hidden';			
		}
	}else if (document.layers && document.layers[object]) {
		if (!document.layers[object].display){
			document.layers[object].display = 'block';
			document.layers[object].visibility = 'visible';				 
		}else if (document.layers[object].display == 'none'){
			document.layers[object].display = 'block';
			document.layers[object].visibility = 'visible';		
		}else{
			document.layers[object].display = 'none';
			document.layers[object].visibility = 'hidden';				
		}
	}else if (document.all) {
		if(!document.all[object].style.display){
			document.all[object].style.display = 'block';
			document.all[object].style.visibility = 'visible';				
		}else if (document.all[object].style.display == 'none'){
			document.all[object].style.display = 'block';
			document.all[object].style.visibility = 'visible';			
		}else{
			document.all[object].style.display = 'none';
			document.all[object].style.visibility = 'hidden';
		}
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}else{
		return false;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = true;
function preloadImages() {
	if (document.images) {
		menut1_over = newImage("skin_1/images/shop/checkout_step1_on.jpg");
		menut2_over = newImage("skin_1/images/shop/checkout_step2_on.jpg");
		menut3_over = newImage("skin_1/images/shop/checkout_step3_on.jpg");
		menut4_over = newImage("skin_1/images/shop/checkout_step4_on.jpg");
		preloadFlag = true;
	}
}

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

function modal_show(){

	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set height and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});

	//transition effect
	$('#mask').fadeIn(1000);
	$('#mask').fadeTo("slow",0.8);
    $("#modal").show("slow");
}

function modal_hide(){
    $("#modal_gallery").hide("slow");
	$('#mask').hide();
}

function start_gallery(type,item_id,image_nr){
	if ($('#modal').html.length>10){
	    start_gallery_generate(image_nr);
	}else{
		$.post("gallery_get.php",
			{ type: type, item_id: item_id },
			function(data){
				$('#modal').html(data);
				start_gallery_generate(image_nr);
				$("#modal_close").click(function(){
				    modal_hide();
				});
			}
		);
	}
}

function start_gallery_generate(image_nr){
    modal_show();
    $('#modal_gallery').center();
    $("#modal_gallery").show();
	//transition effect
	$('#modal_gallery').fadeIn(2000);
    var galleries = $('.ad-gallery').adGallery();
    if (image_nr){
    	galleries[0].showImage(image_nr);
    }
}

