var num;
var dir="images/"+catalogue+"/";
var n;

num=Show.length;
n=3;

function fading() {
 n++;
 if (n>num) n=1;
 
 $("#effect-image2 img").attr({src:dir+Show[0]["img"]+"_"+n+".jpg",title:"",alt:""});
 $("#effect-image1").fadeTo(1000,0);
 $("#effect-image2").fadeTo(1000,1,faded);
}

function faded() {
 $("#effect-image1 img").attr({src:$("#effect-image2 img").attr("src"),title:"",alt:""});
 $("#effect-image1").css("opacity",1);
 $("#effect-image2").css("opacity",0);
}

function previous() {
 if (n<=3) return;
 $("#showcase-box").animate({left:'+=291'}, "slow");
 n--;
 $("#showcase-info").html(n+" of "+num);
 if (n<=3) $("#showcase-btn").html("previous &nbsp; | &nbsp; <a href=\"javascript:void(0);\" onclick=\"next();\">next<\/a>");
 else $("#showcase-btn").html("<a href=\"javascript:void(0);\" onclick=\"previous();\">previous<\/a> &nbsp; | &nbsp; <a href=\"javascript:void(0);\" onclick=\"next();\">next<\/a>");
}
function next() {
 if (n>=num) return;
 $("#showcase-box").animate({left:'-=291'}, "slow");
 n++;
 $("#showcase-info").html(n+" of "+num);
 if (n>=num) $("#showcase-btn").html("<a href=\"javascript:void(0);\" onclick=\"previous();\">previous<\/a> &nbsp; | &nbsp; next");
 else $("#showcase-btn").html("<a href=\"javascript:void(0);\" onclick=\"previous();\">previous<\/a> &nbsp; | &nbsp; <a href=\"javascript:void(0);\" onclick=\"next();\">next<\/a>");
}

$(document).ready(function() {
 $("#showcase-box").css("width",num*291);
 var temp="";
 for (var i=0; i<num; i++) temp+="<li><img src=\""+dir+Show[i]+".jpg\"\ alt=\"\"/><\/li>";
 $("#showcase-box").html(temp);
 $("#showcase-btn").html("previous &nbsp; | &nbsp; <a href=\"javascript:void(0);\" onclick=\"next();\">next<\/a>");
 $("#showcase-info").html(n+" of "+num);
 /*$("#effect-image1 img").attr({src:dir+Show[0]["img"]+"_1.jpg",title:"",alt:""});
 $("#effect-image2 img").attr({src:dir+Show[0]["img"]+"_1.jpg",title:"",alt:""});
 $("#home-box1 h2").html(Show[0]["text1"]);
 $("#home-box2").html(Show[0]["text2"]);
 $("#home-box3 a").attr({src:Show[0]["url"]});
 setInterval(fading,4000);

 $(".conversation-app4 a").click(slidedown);
 if (pop_text=="") {$("#top-popup-bg").hide();}
 else {
  $("#top-popup").html("<a href=\""+pop_link+"\">"+pop_text+"<\/a>");
 }
 $("#show3").fadeTo(0,0);*/
});

function slidedown () {
 slideup();
 $(this).parent().next().slideDown(600);
}
function slideup () {
 $(".conversation-app5").slideUp("slow");
}

function show1() {
 $("#show1").animate({left:'165px'}, "slow");
}
function show1_close() {
 $("#show1").animate({left:'551px'}, "slow");
}

function show2() {
 $("#show2").animate({left:'40px'}, "slow");
}
function show2_close() {
 $("#show2").animate({left:'-346px'}, "slow");
}

function contact_drop() {
 if ($("#CAT_Custom_111499").val()=="advanced") $("#CAT_Custom_111500").show();
 else $("#CAT_Custom_111500").hide();
}

function job_drop() {
 if ($("#CAT_Custom_140698").val()=="Other") $("#CAT_157040").show();
 else $("#CAT_157040").hide();
}

function windowOpener(page,width,height){
  var newWindow = null;
  newWindow = window.open(page,'subscribe','left='+(screen.width-width)/2+', top='+(screen.height-height)/2+',width='+width+', height='+height+', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  newWindow.focus();
}