/**
 * DSAC Javascript
 */
Images = new Array
NumArray = new Array
var a
dbnum = new Array('400','324','445','350','288','417','466','223','494','360','325','467','371','409','233','220','449','316','516','276','470','573','480','308','394');
function preload() {
if (dbnum.length > 5){
for ( var i=1; i<=24; i++) {
    Images[i] = new Image()
    Images[i].src = 'images/gallerysmall/'+ dbnum[i] + '.jpg'}
shuffle()}
}
function shuffle() {
        for (a=0; a<=4; a++) {
            var i = Math.floor(Math.random()*24)
            var ch = checker(i)
            if (ch == false) {
            a--
            }
            else {
            NumArray[a] = i
            }
            };
            document.pic1.src = 'images/gallerysmall/'+dbnum[NumArray[0]]+'.jpg'
            document.pic2.src = 'images/gallerysmall/'+dbnum[NumArray[1]]+'.jpg'
            document.pic3.src = 'images/gallerysmall/'+dbnum[NumArray[2]]+'.jpg'
            document.pic4.src = 'images/gallerysmall/'+dbnum[NumArray[3]]+'.jpg'
            document.pic5.src = 'images/gallerysmall/'+dbnum[NumArray[4]]+'.jpg'
            setTimeout ( 'shuffle()', 4000 )
}
function checker(c) {
    for (b=0;b<=a;b++) {
        if (NumArray[b] == c) {
            return false
        }
    }
}

$(document).ready(function()
{
	slide("#sliding-navigation", 25, 15, 150, .8);
});

function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li.sliding-element";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		$(this).css("margin-left","-180px");
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ marginLeft: "0" }, timer);
		$(this).animate({ marginLeft: "15px" }, timer);
		$(this).animate({ marginLeft: "0" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i)
	{
		$(this).hover(
		function()
		{
			$(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			$(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
}

  // this function is needed to work around 

  // a bug in IE related to element attributes

  function hasClass(obj) {

     var result = false;

     if (obj.getAttributeNode("class") != null) {

         result = obj.getAttributeNode("class").value;

     }

     return result;

  }   



 function stripe(id) {



    // the flag we'll use to keep track of 

    // whether the current row is odd or even

    var even = false;

  

    // if arguments are provided to specify the colours

    // of the even & odd rows, then use the them;

    // otherwise use the following defaults:

    var evenColor = arguments[1] ? arguments[1] : "#fff";

    var oddColor = arguments[2] ? arguments[2] : "#eee";

  

    // obtain a reference to the desired table

    // if no such table exists, abort

    var table = document.getElementById(id);

    if (! table) { return; }

    

    // by definition, tables can have more than one tbody

    // element, so we'll have to get the list of child

    // &lt;tbody&gt;s 

    var tbodies = table.getElementsByTagName("tbody");



    // and iterate through them...

    for (var h = 0; h < tbodies.length; h++) {

    

     // find all the &lt;tr&gt; elements... 

      var trs = tbodies[h].getElementsByTagName("tr");

      

      // ... and iterate through them

      for (var i = 0; i < trs.length; i++) {



        // avoid rows that have a class attribute

        // or backgroundColor style

        if (! hasClass(trs[i]) &&

            ! trs[i].style.backgroundColor) {

 		  

          // get all the cells in this row...

          var tds = trs[i].getElementsByTagName("td");

        

          // and iterate through them...

          for (var j = 0; j < tds.length; j++) {

        

            var mytd = tds[j];



            // avoid cells that have a class attribute

            // or backgroundColor style

            if (! hasClass(mytd) &&

                ! mytd.style.backgroundColor) {

        

              mytd.style.backgroundColor =

                even ? evenColor : oddColor;

            

            }

          }

        }

        // flip from odd to even, or vice-versa

        even =  ! even;

      }

    }

  }
