function clear(){
    if (document.login_form.username.value != "")
		document.login_form.userpass.focus();
    else
		document.login_form.username.focus();
}


function check_delete(eform){
    if (confirm("Figyelem!\nBiztos törli ezt az adatlapot?\nAz összes kapcsolódó adat törlésre kerül!!!"))
	eform.submit();
    else
	return false;
}

function check_delete_answer(eform){
    if (confirm("Figyelem!\nBiztos törli ezt a választ?\nAz összes kapcsolódó adat törlésre kerül!!!"))
	eform.submit();
    else
	return false;
}


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 gallery_window(url){
	if (url != '') {
		window.open(url,'','scrollbars=0,width=800,height=640,top=0,left=0');
	}
}

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

function print_window_product(url){
	if (url != '') {
		window.open(url,'','scrollbars=1,width=820,height=550,top=0,left=0');
	}
}

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

function prospektus() {
	window.open('http://www.skiing.hu/files/prospektus.html','Prospekt','top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=1024,height=720');
} 

function features_list($url) {
	window.open($url,'features','top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1010,height=700');
}

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();
	else{
	    return false;
	}    
    }
    else{
	eform.submit();
    }
}

function checkbox_change(chk){
	var x = document.products_list.elements["manufacturers["+chk+"]"];
	if (x.checked == true){
		x.checked = false;
	}else{
		x.checked = 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);
    if (image_nr){
    	
    }else{
        image_nr = 0;
    }
    var galleries = $('.ad-gallery').adGallery({start_at_index: image_nr});
}


