function shdv(d) {
	$('#' + d).show();
	return true;
}

function hddv(d) {
	$('#' + d).hide();
	return true;
}

function flpdv(d) {
	$('#' + d).toggle();
	return true;
}

function swpimg(i) {
	$('mainimage').src = i;
}

function dsblfrm() {
	$('input[type=submit]').attr('value', '...');
	$('input[type=submit]').attr('disabled', 'disabled');
}

/* app */
function dlgl(g) {
	if (confirm('A galériában található összes fotó el fog veszni!\n\nBiztos törölni akarod a galériát?')) {

		$.ajax({
			type: "POST",
			url: "/ajax/fot_det.php",
			data: {c: 'dlg', g: g},
			success: function(ret){
				$('#gldl_' + g).html(ret);
			}
		});
	}
}


function prodsl(w,g) {
	$.openPopupLayer({
    name: "popup",
    width: w,
    url: "/popup_prodselect.phtml?g=" + g,
    success: function() {
        //alert("It is loaded");
    }
});
}

function prodsl2(w,g) {
	$.openPopupLayer({
    name: "popup",
    width: w,
    url: "/popup_calendarselect.phtml?g=" + g,
    success: function() {
        //alert("It is loaded");
    }
});
}

function bookprvw(b,s) {
	var w,h;
	if (s=='quad') {
		w = 830;
	} else {
		w = 725;
	}
	
	$.openPopupLayer({
    name: "popup",
    width: w,
    url: "/popup_bookprevw.phtml?b=" + b + "&s=" + s,
    success: function() {
        //alert("It is loaded");
    }
});
}


function calendarprvw(b,s) {
	var w,h;
	/*if (s=='quad') {
		w = 830;
	} else {
		w = 725;
	}
	*/
	
	w = 830;
	
	$.openPopupLayer({
    name: "popup",
    width: w,
    url: "/popup_calendarprevw.phtml?b=" + b + "&s=" + s + "&p=0",
    success: function() {
        //alert("It is loaded");
    }
});
}


function coupon() {
	
	$.ajax({
			type: "POST",
			url: "/ajax/cart_coupon.php",
			data: {c: $('#couponcode').val()},
			success: function(ret){
				//$(window.location).attr('href', '/cart/');
				window.location.href = '/cart/';
			}
		});
	
}

function orddtcp() {
	
	$('#ship_name').val($('#inv_name').val());
	$('#ship_zip').val($('#inv_zip').val());
	$('#ship_city').val($('#inv_city').val());
	$('#ship_address').val($('#inv_address').val());
	$('#ship_tel').val($('#inv_tel').val());
}

var dlvprc = 0;
function setDeliveryMethod(m) {
	
	$.ajax({
			type: "POST",
			url: "/ajax/order_form.php",
			data: {d: m},
			success: function(ret){
				$('#order_table').html(ret);
			}
	});
	
	if (m == 1) {
		$('#ship_shop').attr('checked', true);
		hddv('ord_r');
		shdv('shipdaytext');
	} else if (m == 2) {
		$('#ship_sped').attr('checked', true);
		shdv('ord_r');
		hddv('shipdaytext');
	}	
}

function bookdel(b) {
	if (confirm(msgDelBook)) {
		
		$('#dlink_' + b).html('<img src="/img/loader_small.gif" align="absmiddle">')
		
		$.ajax({
			type: "POST",
			url: "/ajax/book_del.php",
			data: {b: b},
			success: function(ret){
				//$(window.location).attr('href', '/order/man/');
				window.location.href = '/order/man/';
			}
		});
		
	}
}

function bookcopy(b,i) {
	
	if (i==1) msgCopyBook = msgCopyBook_1;
	else msgCopyBook = msgCopyBook_2;
	
	if (confirm(msgCopyBook)) {
		
		$('#cplink_' + b).html('<img src="/img/loader_small.gif" align="absmiddle">')
		
		$.ajax({
			type: "POST",
			url: "/ajax/book_copy.php",
			data: {b: b},
			success: function(ret){
				window.location.href = '/order/man/';
			}
		});
	}
		
}


function calendardel(b) {
	if (confirm(msgDelCalendar)) {
		
		$('#dlink_' + b).html('<img src="/img/loader_small.gif" align="absmiddle">')
		
		$.ajax({
			type: "POST",
			url: "/ajax/calendar_del.php",
			data: {b: b},
			success: function(ret){
				//$(window.location).attr('href', '/order/man/');
				window.location.href = '/calendar/orderman/';
			}
		});
		
	}
}

function calendarcopy(b,i) {
	
	if (i==1) msgCopyCalendar = msgCopyCalendar_1;
	else msgCopyCalendar = msgCopyCalendar_2;
	
	if (confirm(msgCopyCalendar)) {
		
		$('#cplink_' + b).html('<img src="/img/loader_small.gif" align="absmiddle">')
		
		$.ajax({
			type: "POST",
			url: "/ajax/calendar_copy.php",
			data: {b: b},
			success: function(ret){
				window.location.href = '/calendar/orderman/';
			}
		});
	}
		
}


function usrmod(f) {
		
	
	
		$.ajax({
			type: "POST",
			url: "/ajax/user_profile.php",
			data: $("#" + f).serialize(),
			success: function(ret){
					
				
				hddv('mod_mail');
				if (f != 'frm_nwdata') clearForm(f);				
				
				$.openPopupLayer({
					    name: "popup",
					    width: 400,
					    url: "/popup_user.phtml?" + ret,
					    success: function() {
					        //alert("It is loaded");
					    }
				});
			},
			error: function (req, txt, err) {
				alert(req.responseText);
			}
		});
		
}

function usrnwlett(f) {

	$.ajax({
		type: "POST",
		url: "/ajax/user_profile.php",
		data: $("#" + f).serialize()
	});
}

function clearForm(f) {
 $('#' + f)[0].reset();
}

//ordersbm

$(function() {
	
	$("input[class='ordersbm']").click(function() {
		this.attr('disabled', 'disabled');
	});
	
	
});

// PROTO

function dlft(f) {
	if (confirm('Biztos törölni akarod a képet?')) {
		new Ajax.Updater('dlfti'+f,'/ajax/fot_det.php', {
  		method: 'post',
  		parameters: {c: 'dl', f: f}
		});
	}
}

function stftop(f) {
	new Ajax.Updater('opftbt'+f,'/ajax/fot_det.php', {
	method: 'post',
	parameters: {c: 'op', f: f}
	});
}
function svftdt(f) {
	new Ajax.Updater('dtftbt'+f,'/ajax/fot_det.php', {
	method: 'post',
	parameters: {c: 'dt', f: f, t: $('imgdt'+f).value}
	});
}

function rot1ft(f) {
	new Ajax.Updater('dlfti'+f,'/ajax/fot_det.php', {
	method: 'post',
	parameters: {c: 'rot1', f: f}
	});
}
function rot2ft(f) {
	new Ajax.Updater('dlfti'+f,'/ajax/fot_det.php', {
	method: 'post',
	parameters: {c: 'rot2', f: f}
	});
}


