﻿// ------------------------------------
// ---------- MENU ROLLOVERS ----------
// ------------------------------------
if (document.images) { 
	//preload images 
	//base image 
	img1= new Image(160,34); 
	img1.src= "../images/menubg_l1.jpg" ; 
	img2= new Image(160,34); 
	img2.src= "../images/menubg_m1.jpg" ; 
	img3= new Image(160,34); 
	img3.src= "../images/menubg_r1.jpg" ;
	img31= new Image(40,34); 
	img31.src= "../images/glendas.jpg" ;
	img4= new Image(203,55); 
	img4.src= "../images/announce.jpg" ;
	img5= new Image(160,200); 
	img5.src= "../images/item_btn.jpg" ;
	imgCat= new Image(200,200); 
	imgCat.src= "../images/mainCat.jpg" ;
	imgBack= new Image(200,200); 
	imgBack.src= "../images/mainCat.jpg" ;
	//hover or rollover image 
	img1r= new Image(160,34); 
	img1r.src= "../images/menubg_l2.jpg" ; 
	img2r= new Image(160,34); 
	img2r.src= "../images/menubg_m2.jpg" ; 
	img3r= new Image(160,34); 
	img3r.src= "../images/menubg_r2.jpg" ; 
	img31r= new Image(40,34); 
	img31r.src= "../images/glendas2.jpg" ;
	img4r= new Image(203,55); 
	img4r.src= "../images/announce_hover.jpg" ; 
	img5r= new Image(160,200); 
	img5r.src= "../images/item_btn_hover.jpg" ; 
	imgCatr= new Image(200,200); 
	imgCatr.src= "../images/mainCat_hover.jpg" ; 
	imgBackr= new Image(200,200); 
	imgBackr.src= "../images/mainCat_hover.jpg" ; 
}

function rollover1(cell) {
    newImage = "url(../images/menubg_l2.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}
function rollout1(cell) {
	newImage = "url(../images/menubg_l1.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}

function rollover2(cell) {
	newImage = "url(../images/menubg_m2.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}
function rollout2(cell) {
	newImage = "url(../images/menubg_m1.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}

function rollover3(cell) {
	newImage = "url(../images/menubg_r2.jpg)";
	newImage2 = "../images/glendas2.gif";
	document.getElementById(cell).style.backgroundImage = newImage;
	document.getElementById('glenda').src = newImage2;
}
function rollout3(cell) {
	newImage = "url(../images/menubg_r1.jpg)";
	newImage2 = "../images/glendas.gif";
	document.getElementById(cell).style.backgroundImage = newImage;
	document.getElementById('glenda').src = newImage2;
}

function rollover4(cell) {
	newImage = "url(../images/announce_hover.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}
function rollout4(cell) {
	newImage = "url(../images/announce.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}

function rollover5(cell) {
	newImage = "url(../images/item_btn_hover.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}
function rollout5(cell) {
	newImage = "url(../images/item_btn.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}

function rolloverCat(cell) {
	newImage = "url(../images/mainCat_hover.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}
function rolloutCat(cell) {
	newImage = "url(../images/mainCat.jpg)";
	document.getElementById(cell).style.backgroundImage = newImage;
}

function rolloverBack(cell) {
	newImage = "../images/back_hover.jpg";
	document.getElementById(cell).src = newImage;
}
function rolloutBack(cell) {
	newImage = "../images/back.jpg";
	document.getElementById(cell).src = newImage;
}

// ---------------------------------------
// ---------- VARIOUS ROLLOVERS ----------
// ---------------------------------------
normal_image = new Image();
normal_image.src = "../images/specials.jpg";

mouseover_image = new Image();
mouseover_image.src = "../images/specials_hover.jpg";

function swap(){
	if (document.images){
		for (var x=0;
		x<swap.arguments.length;
		x+=2) {
		document[swap.arguments[x]].src = eval(swap.arguments[x+1] + ".src");
		}
	}
}


// ------------------------------------
// ---------- PHONE SCROLLER ----------
// ------------------------------------
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden;"><div class="innerDiv" style="position: absolute; left:5px; width: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden;left:5px;" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
// -------- THIS NUMBER CHANGES THE SPEED THAT THE DIVS CHANGE ----------
setTimeout(function(){scrollerinstance.animateup()}, 100)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}



// ---------------------------------------
// ---------- FEATURED SCROLLER ----------
// ---------------------------------------
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
function featuredscroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden;"><div class="innerDiv" style="position: absolute; left:0px; width: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden;left:0px;" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

featuredscroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(featuredscroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

featuredscroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.left)>(this.visibledivtop+5)){
this.visiblediv.style.left=parseInt(this.visiblediv.style.left)-4+"px"
this.hiddendiv.style.left=parseInt(this.hiddendiv.style.left)-4+"px"
// -------- THIS NUMBER CHANGES THE SPEED THAT THE DIVS CHANGE ----------
setTimeout(function(){scrollerinstance.animateup()}, 25)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

featuredscroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

featuredscroller.prototype.getinline=function(div1, div2){
div1.style.left=this.visibledivtop+"px"
div2.style.left=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

featuredscroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

featuredscroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

// -------------------------------------------------------------------
// CHANGE IMAGE ON DETAILS PAGE
// -------------------------------------------------------------------
function swapImage(url) {
	document['itemPic'].src = '../inventory/' + url;
}
function swapBack(url) {
	document['itemPic'].src = '../inventory/' +  url;
}

// -------------------------------------------------------------------
// CHECK CONTACT FORMS
// -------------------------------------------------------------------
function checkContactForm(form) {
	if (form.efn.value == "") {
		alert("Please enter your first name.");
		form.efn.focus();
		return false;
	}
	if (form.eln.value == "") {
		alert("Please enter your last name.");
		form.eln.focus();
		return false;
	}
	if (form.eem.value == "") {
		alert("Please enter your email address.");
		form.eem.focus();
		return false;
	}
	var email = form.eem;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		alert("Please provide a valid email address");
		email.focus();
		return false;
	}
	if (form.esub.value == "") {
		alert("Please enter the subject of your message.");
		form.esub.focus();
		return false;
	}
	if (form.emsg.value == "") {
		alert("Please enter your message.");
		form.emsg.focus();
		return false;
	}
	return true ;
}
// -------------------------------------------------------------------
// CHECK FRIEND FORMS
// -------------------------------------------------------------------
function checkContactForm(form) {
	if (form.efn.value == "") {
		alert("Please enter your first name.");
		form.efn.focus();
		return false;
	}
	if (form.eln.value == "") {
		alert("Please enter your last name.");
		form.eln.focus();
		return false;
	}
	if (form.eem.value == "") {
		alert("Please enter your email address.");
		form.eem.focus();
		return false;
	}
	var email = form.eem;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		alert("Please provide a valid email address");
		email.focus();
		return false;
	}
	if (form.tn.value == "") {
		alert("Please enter your friend's last name.");
		form.eln.focus();
		return false;
	}
	if (form.tem.value == "") {
		alert("Please enter your friend's email address.");
		form.eem.focus();
		return false;
	}
	var email = form.tem;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		alert("Please provide a valid email address");
		email.focus();
		return false;
	}
	return true ;
}

// -------------------------------------------------------------------
// CHECK WISH FORMS
// -------------------------------------------------------------------
function checkWishForm(form) {
	if (form.efn.value == "") {
		alert("Please enter your first name.");
		form.efn.focus();
		return false;
	}
	if (form.eln.value == "") {
		alert("Please enter your last name.");
		form.eln.focus();
		return false;
	}
	if (form.eem.value == "") {
		alert("Please enter your email address.");
		form.eem.focus();
		return false;
	}
	var email = form.eem;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		alert("Please provide a valid email address");
		email.focus();
		return false;
	}
	return true ;
}


// -------------------------------------------------------------------
// CHECK WISH FORMS
// -------------------------------------------------------------------
function popUp(URL,popH,popW) {
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
 screenW = screen.width;
 screenH = screen.height;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
}

screenW = (screenW - popW)/2
screenH = (screenH - popH)/2

day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + popW + ",height=" + popH + ",left = " + screenW + ",top = " + screenH + "');");
}


// -------------------------------------------------------------------
// PRINT DETAILS
// -------------------------------------------------------------------

function print(whatItem) {
		var window_specs = "location=no, scrollbars=yes, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=660px, height=800px";
		var url = "../print/?" + whatItem;

		popup_window = window.open(url, "PrintWindow", window_specs);
		popup_window.focus();
}

function initialize() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		var geocoder = new GClientGeocoder();
		map.setCenter(new GLatLng(39.3390556, -101.576225), 15);
		map.addControl(new GLargeMapControl());
		map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
		var address = new GLatLng(39.3390556, -101.576225)
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
	            } else {
					map.setCenter(new GLatLng(39.3390556, -101.576225), 15);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					marker.openInfoWindowHtml("<span style='font-weight:bold;font-size:15px;'>Cochran Farm Supply</span><br>2702 Road 64<br>Edson, KS 67733<br><strong>785-899-0096</strong>");
				}
			}
		);
	}
}
GSearch.setOnLoadCallback(initialize);
