// JavaScript Document

/**** Motionbox Animation ****/
var show_length = 15000;

/**** Set Testimonial Timeout ****/
function setTestTimeout(seconds){
      var time = seconds * 1000;
      show_length = time;
}
$(document).ready(function(){
    $('#slider').innerfade({
    	  speed: 600,
    	  timeout: show_length,
    	  type: 'random',
    	  containerheight: 'auto'
    });

    $('#testimonials').innerfade({
        speed: 600,
        timeout: show_length,
        type: 'random',
        containerheight: '150px'
    } );
});



/**** Adjust Testimonial Font to fit in box ****/
function adjustTestFont(t){
      var maxheight = '60';
      while($('.tst_quote', t).height() > maxheight){
          newFontSize = parseFloat($('.tst_quote', t).css('font-size')) - 1;
          $('.tst_quote', t).css('font-size',newFontSize);
      }
}


/**** Navigation Dropdown menu ****/
var timeout    = 100;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open(){
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}
function jsddm_close(){
    if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}
function jsddm_timer(){
    closetimer = window.setTimeout(jsddm_close, timeout);
}
function jsddm_canceltimer(){
    if(closetimer){
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

$(document).ready(function(){
    $('#navigation > ul > li').bind('mouseover', jsddm_open)
    $('#navigation > ul > li').bind('mouseout',  jsddm_timer)
});
document.onclick = jsddm_close;




/**** Show / Hide Divs ****/
function showhide(showlayer,hidelayer) {
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( 'document.all.' + showlayer + '.style.display = block');
                eval( 'document.all.' + hidelayer + '.style.display = none');
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[showlayer].display = 'block';
                document.layers[hidelayer].display = 'none';
	}
	if (document.getElementById && !document.all) {
		s = document.getElementById(showlayer);
		s.style.display = 'block';
                h = document.getElementById(hidelayer);
		h.style.display = 'none';
	}
}

/**** open new window ****/
function openWin(elementId){
      var mysel = document.getElementById(elementId);
      var url = mysel.options[mysel.selectedIndex].value;
      
      if(url != ''){
            window.open(url, 'childWin');
      }
      return true;
}

/**** load random Same Day Printing image on home page ****/
var sdLocation = '';
$(document).ready(function(){
      
      if(document.getElementById('samedayimage')){
            imgArr = new Array();
            imgArr[0] = '250GT.jpg';
            imgArr[1] = 'Colorwave.jpg';
            imgArr[2] = 'Docucolor.jpg';
            
            document.getElementById('samedayimage').setAttribute("src", sdLocation + imgArr[Math.round(Math.random()*2)]);
      }
});
function setSDLocation(path){
      sdLocation = path;
}
