// Input 0
var catering = "", filterparam = "", order_by = "", asc_by = "", key, tot_ph = 0, temp = 0, val_mar_sotto = window.innerHeight, flag_open = 0; wimg = 0;
function disableEnterKey(a) {
  return(window.event ? window.event.keyCode : a.which) != 13
}
function capWords(a, b) {
  a = b = document.getElementById(a)[b];
  var c, d;
  c = a.value.toLowerCase();
  stringLen = c.length;
  if(stringLen > 0)for(i = 0;i < stringLen;i++)if(i == 0) {
    b = c.substring(0, 1).toUpperCase();
    c = c.substring(1, stringLen);
    c = b + c
  }else {
    b = c.substring(i, i + 1);
    if(b == " " && i < stringLen - 1) {
      b = c.substring(i + 1, i + 2).toUpperCase();
      d = c.substring(0, i + 1);
      c = c.substring(i + 2, stringLen);
      c = d + b + c
    }
  }a.value = c
}
function EditPost() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(a.responseText !== 0) {
    $(".msg_saved").animate({opacity:1}, 400);
    $(".msg_saved").fadeIn("fast");
    $(".msg_saved").animate({opacity:1}, 800);
    $(".msg_saved").fadeOut("fast");
    $("#btn_save").fadeOut("fast");
    $("#btn_save").animate({opacity:1}, 1600);
    $("#btn_save").fadeIn("fast")
  }
}
function processSend() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(Number(a.responseText) != 0) {
    $("#theform").fadeOut("fast");
    $("#thefeedback").animate({opacity:1}, 1300);
    $("#thefeedback").fadeIn("fast")
  }
}
function updatePost() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)refreshit()
}
function processGetPost() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(Number(a.responseText) == 0)document.getElementById("container").innerHTML = "No results.";
  else document.getElementById("container").innerHTML = a.responseText
}
function processAddPost() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)eval("window.location='" + paramAddPost2 + ".php?" + paramAddPost3 + "=" + paramAddPost1 + "&" + paramAddPost4 + "=" + paramAddPost5 + "'")
}
function refreshit() {
  ajaxpack.postAjaxRequest(proccessurl, key + "", processGetPost, "txt")
}
function change_input_stye(a, b) {
  document.getElementById(a).style.border = "1px solid #666666";
  document.getElementById(a).style.backgroundColor = "#f6f6f6"
}
function empty_Search() {
  document.getElementById("search_Box").value = ""
}
function change_hover_style(a) {
  document.getElementById(a).style.backgroundColor = "#F6F6F6";
  document.getElementById(a).style.border = "1px solid #aaaaaa"
}
function change_input_rtn(a, b) {
  document.getElementById(a).style.backgroundColor = "#F6F6F6";
  document.getElementById(a).style.borderBottom = "1px solid #D1D1D1";
  document.getElementById(a).style.borderTop = "1px solid #F6F6F6";
  document.getElementById(a).style.borderLeft = "1px solid #F6F6F6";
  document.getElementById(a).style.borderRight = "1px solid #F6F6F6";
  if(document.getElementById(a).value == "" || document.getElementById(a).value == "Search")document.getElementById(a).value = "Search"
}
function change_out_style(a) {
  document.getElementById(a).style.backgroundColor = "#F6F6F6";
  document.getElementById(a).style.borderBottom = "1px solid #D1D1D1";
  document.getElementById(a).style.borderTop = "1px solid #F6F6F6";
  document.getElementById(a).style.borderLeft = "1px solid #F6F6F6";
  document.getElementById(a).style.borderRight = "1px solid #F6F6F6"
}
function change_input_back(a) {
  document.getElementById(a).style.backgroundColor = "#F6F6F6";
  document.getElementById(a).style.borderBottom = "1px solid #D1D1D1";
  document.getElementById(a).style.borderTop = "1px solid #F6F6F6";
  document.getElementById(a).style.borderLeft = "1px solid #F6F6F6";
  document.getElementById(a).style.borderRight = "1px solid #F6F6F6"
}
function refreshordit(a, b) {
  ajaxpack.postAjaxRequest(proccessurl, key + "&order_by=" + a + "&asc_by=" + b + "&filterTxt=" + filterparam, processGetPost, "txt")
}
function filterCancel() {
  filterparam = "";
  document.getElementById("filtercancel").style.display = "none";
  document.getElementById("filterbox").value = "Type here";
  ajaxpack.postAjaxRequest(proccessurl, key + "&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=&", processGetPost, "txt")
}
function filterStores() {
  filterparam = "";
  document.getElementById("filtercancel").style.display = "none";
  document.getElementById("filterbox").value = "Type Zip code";
  ajaxpack.postAjaxRequest(proccessurl, key + "&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=&", processGetPost, "txt")
}
function initProcess1(a, b) {
  ajaxpack.postAjaxRequest(a, "&works_series_id="+b+"&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=&", processGet1, "txt")
}
function initProcess2(a, b) {
  ajaxpack.postAjaxRequest(a, b + "&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=&", processGet2, "txt")
}
function initProcess3(a, b) {
  ajaxpack.postAjaxRequest(a, b + "&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=&", processGet3, "txt")
}
function processGet1() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(Number(a.responseText) == 0)document.getElementById("containerpro").innerHTML = "No results.";
  else document.getElementById("containerpro").innerHTML = a.responseText
}
function processGet2() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(Number(a.responseText) == 0)document.getElementById("containerpre").innerHTML = "No results.";
  else document.getElementById("containerpre").innerHTML = a.responseText
}
function processGet3() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)if(Number(a.responseText) == 0)document.getElementById("containersto").innerHTML = "No results.";
  else document.getElementById("containersto").innerHTML = a.responseText
}
function filterList(a) {
  document.getElementById("filtercancel").style.display = "block";
  filterparam = a;
  ajaxpack.postAjaxRequest(proccessurl, key + "&order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=" + filterparam + "&catering=" + catering, processGetPost, "txt")
}
function checkLoading1() {
  $(".loading").fadeIn("fast");
  $(".container1").css("display", "none")
}
function finishLoading1() {
  $(".loading").fadeOut("fast");
  $(".container1").fadeIn("slow")
}
function checkLoading3() {
  $(".loading2").fadeIn("fast");
  $(".container3").css("display", "none")
}
function finishLoading3() {
  $(".loading2").fadeOut("fast");
  $(".container3").fadeIn("slow")
}
function open_img(a) {
	
  $(".prodotto_more").css("display", "none");
  $(".selectedpt img").attr("src", "http://www.ak47space.com/img/dotLight.png");
  $("#" + a + " img").attr("src", "http://www.ak47space.com/img/dotDark.png");
  $("#infop img").attr("src", "http://www.ak47space.com/img/dotInfo.gif");
  $(".prodotto_image").fadeOut();
  
  a = a.substring(1, 3);
  
  wimg = a;
  $("#im" + a).fadeIn()
}
function open_img_next(maxn) {
	
   wimg = Number(wimg)+1; 
   if(maxn<=wimg){wimg = 0;}
      
  $(".prodotto_more").css("display", "none");
  $(".selectedpt img").attr("src", "http://www.ak47space.com/img/dotLight.png");
  $("#p" + wimg + " img").attr("src", "http://www.ak47space.com/img/dotDark.png");
  $("#infop img").attr("src", "http://www.ak47space.com/img/dotInfo.gif");
  $(".prodotto_image").fadeOut();
 
  $("#im" + wimg).fadeIn()
}
function open_pag(a) {
  $(".selectedpt img").attr("src", "http://www.ak47space.com/img/dotLight.png");
  $("#p" + a + " img").attr("src", "http://www.ak47space.com/img/dotDark.png");
  $(".pressdiv").fadeOut()
  $("#pr" + a).fadeIn()
}
function open_page1(a, b, c, d, f) {
	//console.log("open_page1"+a);
	document.location.hash = a.replace("http://www.ak47space.com/","");
	var myhash = a.replace("http://www.ak47space.com","");
  pageTracker._trackPageview(myhash);
  $(".cats").removeClass("selected2");
  $(".cats").fadeOut();
  $("#ICFF").fadeOut(); // ICFF ONLY
  checkLoading1();
  $("a").removeClass("selected1");
  $("a").removeClass("selected2");
  $("#" + c).addClass("selected1");
  vai_giu(a, b, c, d, f)
}
function open_home(a, b, c, d, f) {
		//console.log("open_home"+a);
  $(".cats").removeClass("selected2");
  $(".cats").fadeOut();
  $("#ICFF").fadeIn(); // ICFF ONLY
  checkLoading1();
  $("a").removeClass("selected1");
  $("a").removeClass("selected2");
  vai_giu(a, b, c, d, f)
}
function open_cats(a) {
 		//console.log("open_cats"+a);
  $(".dinbld").removeClass("selected2");
  $(".cats").fadeIn();
  $("#" + a).addClass("selected2");
  
}
function page1(a, b, c, d, f) {
  $(".container1").load(a + ".php", "lang=" + d+"&works_series_id="+f, function() {
 
    finishLoading1()
  })
}
function open_page2(a, b, c, d, f) {
	document.location.hash = f;
		//console.log("open_page2"+f);
  $(".cats").removeClass("selected2");
  $(".cats").fadeOut();
  checkLoading3();
  $("a").removeClass("selected1");
  $("a").removeClass("selected2");
  $("#" + c).addClass("selected2");
  vai_su(a, b, c, d, f); 
  flag_open = 1
}
function open_page3(a, b, c, d, f) {
	document.location.hash = 'products';
		//console.log("open_page3"+f);
  checkLoading3();
  $("a").removeClass("selected1");
  $("a").removeClass("selected2");
  $("#" + c).addClass("selected2");
  $("#plist").addClass("selected2");
 // $("#plist").append(":");
  //Cufon.refresh('.dinbld', { fontFamily: 'dinbld'});

  vai_su(a, b, c, d, f); 
  flag_open = 1
}
function page2(a, b, c, d, f) {
		//console.log("works_id="+b+"works_series_id="+f);
  $("#container3").load(a + ".php", "lang=" + d + "&works_id=" + b+ "&works_series_id=" + f, function() {
 //alert(f);
    finishLoading3()
  })
}
function vai_su(a, b, c, d, f) {
  $("#logo2").fadeIn("slow");
	//console.log("vai_su"+f);
  $("#container1").animate({marginTop:"-500px"}, 700, "swing");
  $("#navigazione").animate({top:"80px"}, 700, "swing");
  $("#subnavigazione").animate({top:"80px"}, 700, "swing", function() {
    page2(a, b, c, d, f); 
  });
  flag_open = 1
}
function vai_giu(a, b, c, d, f) {
		//console.log("vai_giu"+a);
  var e;
  if(self.innerWidth != undefined) {
    e = self.innerWidth;
    e = self.innerHeight
  }else if(document.documentElement.clientWidth != undefined) {
    e = document.documentElement.clientWidth;
    e = document.documentElement.clientHeight
  }else if(window.innerWidth != undefined) {
    e = window.innerWidth;
    e = window.innerHeight
  }$("#logo2").fadeOut("slow");
    $(".prodotto_image").fadeOut("slow");

  $("#container1").animate({marginTop:"0px"}, 700, "swing");
  $("#navigazione").animate({top:e + "px"}, 700, "swing");
  $("#subnavigazione").animate({top:e + "px"}, 700, "swing", function() {
    page1(a, b, c, d, f);
  });
  flag_open = 0
}
function open_info() {
  $(".selectedpt img").attr("src", "http://www.ak47space.com/img/dotLight.png");
  $("#infop img").attr("src", "http://www.ak47space.com/img/dotInfoDark.gif");
  $(".prodotto_image").fadeOut("fast");
  $(".prodotto_more").fadeIn("slow")
}
function close_info() {
  $("#infop img").attr("src", "http://www.ak47space.com/img/dotInfo.gif");
  $(".prodotto_more").fadeOut("fast");
  $("#im0").attr("src", "http://www.ak47space.com/img/dotDark.png")
}
function refreshme() {
  var a;
  if(self.innerWidth != undefined)a = self.innerHeight;
  else if(document.documentElement.clientWidth != undefined)a = document.documentElement.clientHeight;
  else if(window.innerWidth != undefined)a = window.innerHeight;
  if(flag_open == 0) {
    $("#navigazione").css("top", a + "px");
    $("#subnavigazione").css("top", a + "px")
  }$(".prodotto_image").css("height", a - 100 + "px");
  $(".prodotto_image img").css("height", a - 100 + "px");
  
  $(".prodotti_arrows").css("top", a - 109 + "px")
}
function searchBox_clear() {
  var a = document.getElementById("search_Box");
  if(a.value == "Search")a.value = ""
}
function changeMyValue(a) {
  if(document.getElementById(a).checked)document.getElementById(a).value = "1";
  else document.getElementById(a).value = "0"
}
function MM_preloadImages() {
  var a = document;
  if(a.images) {
    if(!a.MM_p)a.MM_p = [];
    var b, c = a.MM_p.length, d = MM_preloadImages.arguments;
    for(b = 0;b < d.length;b++)if(d[b].indexOf("#") != 0) {
      a.MM_p[c] = new Image;
      a.MM_p[c++].src = d[b]
    }
  }
}
function MM_swapImgRestore() {
  var a, b, c = document.MM_sr;
  for(a = 0;c && a < c.length && (b = c[a]) && b.oSrc;a++)b.src = b.oSrc
}
function MM_findObj(a, b) {
  var c, d;
  b || (b = document);
  if((c = a.indexOf("?")) > 0 && parent.frames.length) {
    b = parent.frames[a.substring(c + 1)].document;
    a = a.substring(0, c)
  }if(!(d = b[a]) && b.all)d = b.all[a];
  for(c = 0;!d && c < b.forms.length;c++)d = b.forms[c][a];
  for(c = 0;!d && b.layers && c < b.layers.length;c++)d = MM_findObj(a, b.layers[c].document);
  if(!d && b.getElementById)d = b.getElementById(a);
  return d
}
function MM_swapImage() {
  var a, b = 0, c, d = MM_swapImage.arguments;
  document.MM_sr = [];
  for(a = 0;a < d.length - 2;a += 3)if((c = MM_findObj(d[a])) != null) {
    document.MM_sr[b++] = c;
    if(!c.oSrc)c.oSrc = c.src;
    c.src = d[a + 2]
  }
}
function publishit(a, b, c) {
  ajaxpack.postAjaxRequest("process_submitit.php", "order_by=" + order_by + "&asc_by=" + asc_by + "&pre_table=" + a + "&id=" + b + "&filterTxt=" + filterparam + "&catering=" + catering + "&val=" + c, processpublishit, "txt")
}
function checked_it(a, b, c, d) {
  ajaxpack.postAjaxRequest("process_submititslide.php", "order_by=" + order_by + "&asc_by=" + asc_by + "&pre_table=" + a + "&pre_row=" + b + "&id=" + c + "&val=" + d, processpublishit, "txt")
}
function processpublishit() {
  var a = ajaxpack.ajaxobj, b = ajaxpack.filetype;
  if(a.readyState == 4)if(a.status == 200 || window.location.href.indexOf("http") == -1)ajaxpack.postAjaxRequest(proccessurl, "order_by=" + order_by + "&asc_by=" + asc_by + "&filterTxt=" + filterparam + "&catering=" + catering + "&" + key, processGetPost, "txt")
}
function deleteit(a) {
  a != false && ajaxpack.postAjaxRequest(proccessurl, key + "action=delete&id=" + a, processGetPost, "txt")
}
function movedw(a) {
  ajaxpack.postAjaxRequest(proccessurl, key + "&action=movedw&id=" + a, processGetPost, "txt")
}
function moveup(a) {
  ajaxpack.postAjaxRequest(proccessurl, key + "&action=moveup&id=" + a, processGetPost, "txt")
}
function formReset(a) {
  document.getElementById(a).reset()
}
function startUpload(a) {
  document.getElementById("upload_loader").style.visibility = "visible";
  document.getElementById("upload_msg").innerHTML = "";
  document.getElementById("upload_msg").style.visibility = "hidden";
  a = document.getElementById(a);
  var b = {};
  b = "";
  for(var c = 0;c < a.elements.length;c++) {
    ele = a.elements[c];
    if(ele.type == "file") {
      b = ele.value;
      b = b.indexOf("/") > -1 ? b.substring(b.lastIndexOf("/") + 1, b.length) : b.substring(b.lastIndexOf("\\") + 1, b.length);
      break
    }
  }if(b.replace("/s/", "").toString() !== "") {
    a.submit();
    return true
  }
}
function stopUpload(a) {
  var b = "";
  b = a == "1" ? '<div class="msg">File Uploaded!</div><br />' : a == "2" ? '<div class="emsg">Error. <br/>Filename contains invalid characters (ex. %$^&*#@).  <br/>Retry by renaming your file.</div><br />' : '<div class="emsg">Error. File not uploaded. Retry.</div><br />';
  document.getElementById("upload_loader").style.visibility = "hidden";
  document.getElementById("upload_msg").innerHTML = b;
  document.getElementById("upload_msg").style.visibility = "visible";
  return true
}
function changeTitle(a, b) {
  for(i = 0;i < b;i++)document.getElementById("title" + i).style.marginLeft = "-3600px";
  document.getElementById("title" + a).style.marginLeft = "0px"
}
	
    function loadimg(e,d,c) {
        var img = new Image();
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#'+d+' img').removeClass('loading').replaceWith(this);
            $('#'+d+' img').css('width','255px');
            $('#'+d+' img').css('float','right');
           
			
            $('.prodotto_moretumb img').removeClass('moretumb_tselect');
            $('.prodotto_moretumb img').addClass('moretumb_notselect');
		 
            $('#'+c+' img').addClass('moretumb_tselect');
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', e);
    }
	



function openFlash() {
  $("#flash_slideshow").animate({height:"280px"}, 1E3)
}
function closeFlash() {
  $("#flash_slideshow").animate({height:"0px"}, 1E3)
}
function showName(a) {
  $("#" + a).animate({opacity:1}, {duration:"fast", queue:false})
}
function hideName() {
  $(".thisname").animate({opacity:0}, {duration:"fast", queue:false})
}
;
