
var selected;
var submitter = null;

function submitFunction() {
    submitter = 1;
}

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.getElementById('payment'[0])) {
    document.getElementById('payment'[buttonSelect]).checked=true;
  } else {
    //document.getElementById('payment'[selected]).checked=true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function popupImageWindow(url) {
  window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=600,screenX=150,screenY=150,top=150,left=150')
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=600,screenX=150,screenY=150,top=150,left=150')
}

function showImage(image){
    var image2 = image.replace("info_images","popup_images");
    var img = document.createElement("img");
    var p = document.createElement("p");
    p.style.textalign = "center";
    p.innerHTML = "schließen";
    img.setAttribute("src", image2);
    $("#popupContainer").css("opacity","0");
    $("#popupContainer").css("display","block");
    $("#popup *").remove();
    $("#popup").append(img);
    $("#popup").append(p);
    $("#page").animate({opacity:.1},1000);
    $("#popupContainer").delay(1000).animate({opacity:1},1000);
    return false;
}

function hideImage(){
    $("#popupContainer").animate({opacity:0},1000, function(){$(this).css("display","none");});
    $("#page").animate({opacity:1},1000);
}

function showPopupContainer(){
    $("#popupContainer").css("opacity","1");
    $("#popupContainer").css("display","block");
    $("#page").css("opacity","0.1");
}

function hidePopupContainer(){
    $("#popupContainer").animate({opacity:0},1000, function(){$(this).css("display","none");});
    $("#page").animate({opacity:1},1000);
}

function showAdmin(){
	$("#admin div:nth-child(2)").css("overflow","hidden");
	$("#admin div:nth-child(2)").animate(
		{height:'toggle'},
		1000,
		function() {$("#admin div:nth-child(2)").css("display","");}
		);
}
function hideAdmin(){
	$("#admin div:nth-child(2)").css("overflow","hidden");
	$("#admin div:nth-child(2)").delay(1000).animate(
		{height:'toggle'},
		1000,
		function() {$("#admin div:nth-child(2)").css("display","none");}
		);
}

function checkoutSubmit(){
    $("#popupContainer").unbind('click');
    showPopupContainer();
    document.getElementById("popup").innerHTML = "<div>Die Bestellung wird gespeichert...</div>";
    var img = document.createElement("img");
    img.setAttribute("src", "/templates/futterspatz/img/loading.gif");
    $("#popup").append(img);
    $("#popup").css("width","400px");
    $("#popup").css("padding","50px");
}

$(document).ready(function(){
    // $("#admin div:nth-child(2)").css("display","none");
    // $("#admin").mouseenter(showAdmin).mouseleave(hideAdmin);
    $('#checkout_confirmation_submit').click( checkoutSubmit );
    $('#checkout_confirmation_submit_top').click( checkoutSubmit );
    $('#checkout_confirmation_submit_bottom').click( checkoutSubmit );
    $("#popupContainer").css("display","none");
    $("#popupContainer").click( hideImage );
    // $("#popup").click( function(){$(this).css("display","none");} );
    var img = new Image(32,32);
    img.src = "/templates/futterspatz/img/loading.gif";
});


