// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}





$(function() {
	$(document).ready(function() {
		$("#SlideShow").cjSimpleSlideShow();
	//if ( document.forms["contact"]){
		//checkLinks();
		//}
	//if (document.getElementById("conMessage")){
		//getCookie()}
	});
});

(function($) {
	$.fn.cjSimpleSlideShow = function(options) {

		var settings = {
			// user editable settings
			autoRun: true,
			delay: 3000,
			dissolve: 70,
			showCaptions: false,
			centerImage: false
		};

		var sys = {
			// function parameters
			version: '2.1.1',
			elem: null,
			slides: [],
			captions: [],
			current: 0,
			timer: null,
			pause: false
		};

		/* 
			sets a slides opacity
		***************************************/
		function setOpacity(o) {
			if (parseFloat(o.t) > 1) {
				o.t = 1.0;
				return;
			}
			$(o).css({
				"opacity": parseFloat(o.t),
				"MozOpacity": parseFloat(o.t),
				"filter": "alpha(opacity=" + (parseFloat(o.t) * 100) + ")"
			});
		}

		/* 
			sets the slide and handles dissolves
		***************************************/
		function setSlide() {
			var o = parseFloat(sys.slides[sys.current].t);
			var x = sys.slides[sys.current + 1] ? sys.current + 1 : 0;
			var no = parseFloat(sys.slides[x].t);
			o -= 0.05;
			no += 0.05;
			$(sys.slides[x]).css({
				"display": "block"
			});
			sys.slides[sys.current].t = parseFloat(o);
			sys.slides[x].t = parseFloat(no);
			setOpacity(sys.slides[sys.current]);
			setOpacity(sys.slides[x]);
			if (sys.captions[sys.current] && sys.captions[x]) {
				$(sys.captions[x]).css({
					"display": "block"
				});
				sys.captions[sys.current].t = parseFloat(o);
				sys.captions[x].t = parseFloat(no);
				setOpacity(sys.captions[sys.current]);
				setOpacity(sys.captions[x]);
			}
			if (o <= 0) {
				$(sys.slides[sys.current]).css({
					"display": "none"
				});
				if (sys.captions[x]) {
					$(sys.captions[x]).css({
						"display": "block"
					});
					$(sys.captions[sys.current]).css({
						"display": "none"
					});
				}
				sys.current = x;
				if (!sys.pause) {
					sys.timer = setTimeout(setSlide, settings.delay);
				}
			} else {
				if (!sys.pause) {
					sys.timer = setTimeout(setSlide, settings.dissolve);
				}
			}
		}

		/* 
			pauses the slideshow
		***************************************/
		function pause() {
			sys.pause = true;
			if (sys.timer) {
				clearTimeout(sys.timer);
				sys.timer = null;
			}
			$(sys.elem).find("div.cj_slideshow_pause_wrapper").fadeIn("fast");
		}

		/* 
			resumes the slideshow
		***************************************/
		function resume() {
			sys.pause = false;
			$(sys.elem).find("div.cj_slideshow_pause_wrapper").fadeOut("fast");
			sys.timer = setTimeout(setSlide, 0);
		}

		/* 
			initialize the slideshow & slides
		***************************************/
		function init() {

			// need to make sure the positioning is set for the main container.
			// it needs to be set to anything other than STATIC
			if ($(sys.elem).css("position") === "" || $(sys.elem).css("position") === "static") {
				$(sys.elem).css("position", "relative");
			}

			// create our main slideshow wrapper
			var i, wrapper = $("<div>").css({
				"display": "block",
				"width": "0px",
				"height": "0px",
				"position": "absolute",
				"overflow": "hidden",
				"cursor": "default"
			}).addClass("cj_slideshow_wrapper"),
			pauseBlock = $("<div>").css({
				"display": "none",
				"position": "absolute",
				"z-index": "10"
			}).html("Paused").addClass("cj_slideshow_pause_wrapper");

			// loop through the images and initialize some settings
			$(sys.elem).find("img").each(function() {
				sys.slides.push($(this).get(0));
			}).css({
				"position": "absolute",
				"top": "0px",
				"left": "0px"
			}).wrapAll($(wrapper));
			$(sys.elem).find("div.cj_slideshow_wrapper").append(pauseBlock)//.bind("mouseenter", function() {
				//pause();
			//}).bind("mouseleave", function() {
				//resume();
			//});
			$(sys.elem).find("br").css({
				"display": "none"
			});

			$(sys.elem).css({
				"display": "block"
			});

			// center the image? we need the images to have the display set to none in order to start the transitions
			// but in order to get the width and height in Internet Explorer, they need to be visible... (or display=block)
			$(sys.elem).find("img").each(function() {
				var i = this;
				if (settings.centerImage) {
					$(i).css({
						"display": "none",
						"top": settings.centerImage ? parseInt(($(sys.elem).height() - $(i).attr("height")) / 2, 10) + "px": "0px",
						"left": settings.centerImage ? parseInt(($(sys.elem).width() - $(i).attr("width")) / 2, 10) + "px": "0px"
					});
				} else {
					$(i).css({
						"display": "none"
					});
				}
			});

			// captions?
			for (i = 0; i < sys.slides.length; i++) {
				sys.slides[i].t = 0.0;
				if (settings.showCaptions) {
					if ($(sys.slides[i]).attr("alt") !== "") {
						var cap = $("<span>").css({
							"position": "absolute",
							"display": "none",
							"width": "100%",
							"height": "auto"
						}).addClass("cj_slideshow_caption_wrapper").html($(sys.slides[i]).attr("alt"));
						$(sys.slides[i]).after(cap);
						sys.captions.push($(sys.slides[i]).next("span"));
						sys.captions[i].t = 0.0;
					} else {
						sys.captions.push(null);
						sys.captions[i].t = 0.0;
					}
				}
			}

			// make the first slide and/or caption visisable
			if (sys.slides.length > 0) {
				$(sys.slides[0]).css({
					"display": "block"
				});
				sys.slides[0].t = 1.0;
				if (sys.captions[0]) {
					$(sys.captions[0]).css({
						"display": "block"
					});
					sys.captions[0].t = 1.0;
				}
				// show our main elem, if it was hidden
				$(sys.elem).find(".cj_slideshow_wrapper").css({
					"width": $(sys.elem).width(),
					"height": $(sys.elem).height()
				});
			}

		}

		function start() {
			sys.timer = setTimeout(setSlide, settings.delay);
		}

		/* 
			set up any user passed variables
		***************************************/
		if (options) {
			$.extend(settings, options);
		}

		/* 
			begin
		***************************************/
		return this.each(function() {
			sys.elem = this;
			init();
			if (settings.autoRun) {
				start();
			}
		});

	};
})(jQuery);


/*function checkLinks(){
	var aTags = document.getElementsByTagName("input");
	
	for(var i=0; i<aTags.length; i++){
			if(aTags[i].className == "order"){
					aTags[i].onclick = function(){
							makeCookie(this.title);
							return false;
							
						}
				}
		}
}
function makeCookie(itemName){
	
	var bits = document.forms["contact"].elements;
	
	var chunks = itemName+"=";
				
	for(var i=0; i<bits.length; i++){
			chunks += bits[i].value +"&&&";
			//+= takes the current var and adds new information
	}
	
	var date = new Date("February 14, 2050");
	date = date.toGMTString();
	
	document.cookie = chunks +"; expires="+date+"; path=/;";
	
	window.location.href = "confirm.html";
	
}

function getCookie(){
	var target = document.getElementById("conMessage");
	var c = document.cookie;
	if(c !=""){
		
	c = c.split(";");
	var overallTotal=0;
	for(var i=0; i<c.length; i++)
		{
			//rhino=1&&&9 inch&&&11.00;
			var broken = c[i].split("=");
			//rhino = broken[0]
			//1&&&9 inch&&&11.00 = broken[1]
			
			var values = broken[1].split("&&&");
			//v[0]=1 v[1]=9 inch	v[2]=11.00
			
			var h3Tag = document.createElement("h3");
			//var title = document.createTextNode(broken[0]);
			//h3Tag.appendChild(title);
			//target.appendChild(h3Tag);
			
			//var price = (values[0])*(values[(values.length-2)]);
			//overallTotal += price;
			//var priceTag = document.createElement("p");
			//var displayPrice = document.createTextNode("SubTotal : $"+price);
			
			
			
			for(var j=0; j<values.length; j++)
				{
					var data = document.createTextNode(values[j]);
					var brTag = document.createElement("br");
					
					target.appendChild(data);
					target.appendChild(brTag);
				}
			//var remove = document.createElement("a");
			//var removeTxt = document.createTextNode("remove");
			//remove.setAttribute("href","confirm.html");
			//remove.setAttribute("title",broken[0]);
			//remove.onclick = function() {
				//removeCookie(this.title);				
			//}
			//priceTag.appendChild(displayPrice);
			//target.appendChild(priceTag);
			//remove.appendChild(removeTxt);
			//target.appendChild(remove);
		}
		//var totalPrice = document.createTextNode("TOTAL PRICE "+overallTotal);
		//var totalDiv = document.createElement("div");
			//totalDiv.setAttribute("style","position:absolute; right:0px; top:0px; width:100px; height:50px; background-color:#CCC;");
			
			//totalDiv.appendChild(totalPrice);
			//target.appendChild(totalDiv);
}
	else {
	var noCookie = document.createElement("span");
	var noTxt = document.createTextNode("No message was sent.");
	noCookie.appendChild(noTxt);
	target.appendChild(noCookie);
	}

}
*/

