﻿// JScript File
/* Browser Check */

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();




/* Navigation Hovers */

   function preloadHovers() {
        $('#link1 img').mouseover(function() {
            $("#link1 img").animate({opacity: 0}, 500 );
        });
            
        $('#link1 img').mouseout(function() {
            $("#link1 img").animate({opacity: 1.0}, 500 );
        });
        
        $('#link2 img').mouseover(function() {
            $("#link2 img").animate({opacity: 0}, 500 );
        });
            
        $('#link2 img').mouseout(function() {
            $("#link2 img").animate({opacity: 1.0}, 500 );
        });
        
        $('#link3 img').mouseover(function() {
            $("#link3 img").animate({opacity: 0}, 500 );
        });
            
        $('#link3 img').mouseout(function() {
            $("#link3 img").animate({opacity: 1.0}, 500 );
        });
        
        $('#link4 img').mouseover(function() {
            $("#link4 img").animate({opacity: 0}, 500 );
        });
            
        $('#link4 img').mouseout(function() {
            $("#link4 img").animate({opacity: 1.0}, 500 );
        });   
        
        $('#link5 img').mouseover(function() {
            $("#link5 img").animate({opacity: 0}, 500 );
        });
            
        $('#link5 img').mouseout(function() {
            $("#link5 img").animate({opacity: 1.0}, 500 );
        });
        
        $('#link6 img').mouseover(function() {
            $("#link6 img").animate({opacity: 0}, 500 );
        });
            
        $('#link6 img').mouseout(function() {
            $("#link6 img").animate({opacity: 1.0}, 500 );
        });
        
        $('#link7 img').mouseover(function() {
            $("#link7 img").animate({opacity: 0}, 250 );
        });
            
        $('#link7 img').mouseout(function() {
            $("#link7 img").animate({opacity: 1.0}, 250 );
        });
        
        $('#bigbtn1').mouseover(function() {
            $("#bigbtn1").animate({opacity: 0}, 250 );
        });
            
        $('#bigbtn1').mouseout(function() {
            $("#bigbtn1").animate({opacity: 1.0}, 250 );
        });
        
        $('#bigbtn2').mouseover(function() {
            $("#bigbtn2").animate({opacity: 0}, 250 );
        });
            
        $('#bigbtn2').mouseout(function() {
            $("#bigbtn2").animate({opacity: 1.0}, 250 );
        });
}
    
// Used for the initial setup of the Services / Products pages 
function topiconSetup() {
    $("#ico1").css("opacity",".75");
    $("#ico1").css("filter","alpha(opacity=75)");
    $("#ico2").css("opacity",".75");
    $("#ico2").css("filter","alpha(opacity=75)");
    $('#ico1').mouseover(function() {
        $("#ico1").animate({opacity: 1.0}, 500 );
    });
        
    $('#ico1').mouseout(function() {
        $("#ico1").animate({opacity: .75}, 500 );
    });
    
     $('#ico2').mouseover(function() {
        $("#ico2").animate({opacity: 1.0}, 500 );
    });
        
    $('#ico2').mouseout(function() {
        $("#ico2").animate({opacity: .75}, 500 );
    });
  
}
    
// Used for the functionality of the section swapping in Services and Products
function topbtnSetup() {
    if(('#topbtn1')) {
        $('#topbtn1').unbind();
        $("#topbtn1").css("opacity",".5");
        $("#topbtn1").css("filter","alpha(opacity=50)");
        $('#topbtn1').mouseover(function() {
            $("#topbtn1").animate({opacity: 1.0}, 500 );
        });
            
        $('#topbtn1').mouseout(function() {
            $("#topbtn1").animate({opacity: .5}, 500 );
        });
    }
    
    if(('#topbtn2')) {
        $('#topbtn2').unbind();
        $("#topbtn2").css("opacity",".5");
        $("#topbtn2").css("filter","alpha(opacity=50)");
        $('#topbtn2').mouseover(function() {
            $("#topbtn2").animate({opacity: 1.0}, 500 );
        });
            
        $('#topbtn2').mouseout(function() {
            $("#topbtn2").animate({opacity: .5}, 500 );
        });
    }
    
    if(('#topbtn3')) {
        $('#topbtn3').unbind();
        $("#topbtn3").css("opacity",".5");
        $("#topbtn3").css("filter","alpha(opacity=50)");
        $('#topbtn3').mouseover(function() {
            $("#topbtn3").animate({opacity: 1.0}, 500 );
        });
            
        $('#topbtn3').mouseout(function() {
            $("#topbtn3").animate({opacity: .5}, 500 );
        });
    }
    
    if(('#topbtn4')) {
        $('#topbtn4').unbind();
        $("#topbtn4").css("opacity",".5");
        $("#topbtn4").css("filter","alpha(opacity=50)");
        $('#topbtn4').mouseover(function() {
            $("#topbtn4").animate({opacity: 1.0}, 500 );
        });
            
        $('#topbtn4').mouseout(function() {
            $("#topbtn4").animate({opacity: .5}, 500 );
        });
    }

}

function showInfoSection(id) {
    // First hide all others
    var divs = document.getElementById("right").getElementsByTagName("div");
    for(i=0;i<divs.length;i++){
        if(divs[i].className == "infoarea")
            divs[i].style.display = "none";               
    
    }
    topbtnSetup();       
    $('#topbtn' + id).unbind();
    $("#topbtn" + id).css("opacity","1.0");
    $("#info" + id).fadeIn(500);
}
    
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13))  {return false;}
} 

function print_mail_to_link(which){
    var lhs = '';
    var rhs = '';
    if(which == 0) {
        lhs = 'info';
        rhs = 'badgerroll.net';
    }else if(which == 1) {
        lhs = 'blenius';
        rhs = 'badgerroll.net';
    }else if(which == 2) {
        lhs = 'ajjohnson';
        rhs = 'badgerroll.net';
    }else if(which == 3) {
        lhs = 'cellingson';
        rhs = 'badgerroll.net';
    }else if(which == 4) {
        lhs = 'rwolcott';
        rhs = 'badgerroll.net';
    }else if(which == 5) {
        lhs = 'jmalchak';
        rhs = 'badgerroll.net';
    }else if(which == 6) {
        lhs = 'rdemille';
        rhs = 'badgerroll.net';
    }else if(which == 7) {
        lhs = 'johnclarke';
        rhs = 'badgerroll.net';
    }
    document.write('<a href=\"mailto: ' + lhs + '@' + rhs + '\">' + lhs + '@' + rhs + '</a>');
}

/* Contact Page */

function showRegion(state) {
    var divs = document.getElementById("map_cont").getElementsByTagName("div");
    for(i=0;i<divs.length;i++) {
        if(divs[i].className == "state_details")
            divs[i].style.display = "none";
    }
    if(!document.getElementById("st_"+state)) 
        document.getElementById("st_default").style.display = "block"; 
    else
        document.getElementById("st_"+state).style.display = "block";
}
function contactRep(firstpart, secondpart) {
    document.getElementById("recipient").style.display = "block";
    var recipient=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_txtRecipient');
    recipient.value = firstpart + "@" + secondpart;
    window.location="#form";
}


