$(function() {

    $('#slides').cycle({
    fx:     'fade', 
    speed:  'slow', 
    timeout: 6000
    });



$("a[href^='http']").not("[href*='shieldgold.com']").click(function(){
	window.open(this.href);
	return false;
});


$("a[href*=.pdf]").click(function(){
	window.open(this.href);
	return false;
});




$("a[href$='.pdf']").addClass("pdf");
$("a[href$='.doc']").addClass("doc");

       $('.gallery').each(function(){
            $('.lightbox', this).lightBox({
	imageLoading: '/template/images/lightbox-ico-loading.gif',
	imageBtnClose: '/template/images/lightbox-btn-close.gif',
	imageBtnPrev: '/template/images/lightbox-btn-prev.gif',
	imageBtnNext: '/template/images/lightbox-btn-next.gif'
         });
        });

$('.image').lightBox({
	imageLoading: '/template/images/lightbox-ico-loading.gif',
	imageBtnClose: '/template/images/lightbox-btn-close.gif',
	imageBtnPrev: '/template/images/lightbox-btn-prev.gif',
	imageBtnNext: '/template/images/lightbox-btn-next.gif'
         });



        $('a[href*=#]').click(function() {
          if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
              var targetOffset = $target.offset().top;
              $('html,body')
              .animate({scrollTop: targetOffset}, 1000);
             return false;
            }
          }
        });


        $("ul.sf-menu").supersubs({ 
            minWidth:    10,   // minimum width of sub-menus in em units 
            maxWidth:    37,   // maximum width of sub-menus in em units 
            extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
		}).superfish({
		    autoArrows:    false,
		    dropShadows:   false,               
		    disableHI:     false
	});



				

});





function addLoadEvent(func){
    var oldonload = window.onload;
    if(typeof window.onload != 'function'){
        window.onload = func;
    }else{
        window.onload = function(){
            oldonload();
            func();
        }
    }
}


/*---- Grey Initial Values ------ */

function greyInitialValues(){

	var filled = getElementsByClassName("filled");
	if(filled.length > 0){
		for(var i = 0; i < filled.length; i++){
			filled[i].className = "empty";
			filled[i].initialValue = filled[i].value;
			
			filled[i].onclick = filled[i].onfocus = function(){
				this.className = "filled";
				if(this.value == this.initialValue){
					this.value= "";
				}
			}
			
			filled[i].onblur = function(){
				if(this.value == this.initialValue || this.value == ""){
					this.className = "empty";
					this.value = this.initialValue;
				}else{
					this.className = "filled";
				}
			}
		}
	}else{return;}
}
addLoadEvent(greyInitialValues);

/*---- Grey Initial Values ------ */

/* -----    getElementsByClassName  -----
	by SCOTT SCHILLER
	http://www.schillmania.com
-----------------------------------*/

function getElementsByClassName(className,oParent) {
  var doc = (oParent||document);
  var matches = [];
  var nodes = doc.all||doc.getElementsByTagName('*');
  for (var i=0; i<nodes.length; i++) {
    if (nodes[i].className == className || nodes[i].className.indexOf(className)+1 || nodes[i].className.indexOf(className+' ')+1 || nodes[i].className.indexOf(' '+className)+1) {
      matches[matches.length] = nodes[i];
    }
  }
  return matches; // kids, don't play with fire. ;)
}



