// ****************** JQUERY  ****************** //

        $.fn.infiniteCarousel = function () {
     
        function repeat(str, num) {
            return new Array( num + 1 ).join( str );
        }
      
        return this.each(function () {
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul'),
                $items = $slider.find('> li'),
                $single = $items.filter(':first'),
                
                singleWidth = $single.outerWidth(), 
                visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
                currentPage = 1,
                pages = Math.ceil($items.length / visible);            
     
     
            // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
            if (($items.length % visible) != 0) {
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }
     
            // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
            $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li'); // reselect
            
            // 3. Set the left position to the first 'real' item
            $wrapper.scrollLeft(singleWidth * visible);
            
            // 4. paging function
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;
                
                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    if (page == 0) {
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                        page = pages;
                    } else if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        // reset back to start position
                        page = 1;
                    } 
     
                    currentPage = page;
                });                
                
                return false;
            }
            
            $wrapper.after('<a class="arrow back" id="arrowBack">&lt;</a><a class="arrow forward" id="arrowforward">&gt;</a>');
            
            // 5. Bind to the forward and back buttons
            $('a.back', this).click(function () {
                //pageTracker._trackEvent('INFINITE_CAROUSEL','BACK');
                return gotoPage(currentPage - 1);                
            });
            
            $('a.forward', this).click(function () {
                //pageTracker._trackEvent('INFINITE_CAROUSEL','FORWARD');
                return gotoPage(currentPage + 1);
            });
            
            // create a public interface to move to a specific page
            $(this).bind('goto', function (event, page) {
                gotoPage(page);
            });
        });  
    };




// ****************** PLATFORM DETECTION FOR STYLE SHEET SELECTION ****************** //
	/*var ver = navigator.appVersion.toLowerCase();

	if (ver.indexOf("mac") != -1) {

	// platform is Macintosh
		document.write('<LINK REL="stylesheet" HREF="/style/styleSheetMac.css" TYPE="text/css">');
		} else 
				{
	// platform is Windows
		document.write('<LINK REL="stylesheet"  HREF="/style/styleSheetWindows.css" TYPE="text/css">');
		}*/

// ****************** POPUP WINDOW CODE ****************** //
	function popup(theURL,theWidth,theHeight,theWindowName){
	  popWindow = window.open(theURL, theWindowName, "scrollbars=yes,location=no,menubar=yes,toolbar=yes,resizable=yes,status=no,width="+theWidth+",height="+theHeight);
	}
	
	var newwindow;
    function poptastic(url)
    {
	    newwindow=window.open(url,'name','height=505,width=750');
	    if (window.focus) {newwindow.focus()}
    }


// ****************** IE3 SAFE IMAGE SWITCHING CODE ****************** //
	var goodBrowser = 0;

	if(document.images){
			// enable rollovers
			goodBrowser = 1;
			
			//image preloading stuff
			//put your images that will be used into a comma delimited
			//list on the next line... follow the example =)
			var preLoad = new Array('/images/navigation/Sentry_AboutSentry.jpg','/images/navigation/Sentry_AboutSentry-over.jpg',
			                        '/images/navigation/Sentry_AboutYourSafe-over.jpg','/images/navigation/Sentry_AboutYourSafe.jpg',
			                        '/images/navigation/Sentry_Accessories-over.jpg','/images/navigation/Sentry_Accessories.jpg',
			                        '/images/navigation/Sentry_BrowsAllSafes-over.jpg','/images/navigation/Sentry_BrowsAllSafes.jpg',
			                        '/images/navigation/Sentry_BusinessSafes-over.jpg','/images/navigation/Sentry_BusinessSafes.jpg',
			                        '/images/navigation/Sentry_CantOpenSafe-over.jpg','/images/navigation/Sentry_CantOpenSafe.jpg',
			                        '/images/navigation/Sentry_ContactsUs-over.jpg','/images/navigation/Sentry_ContactsUs.jpg',
			                        '/images/navigation/Sentry_CustomerCare-over.jpg','/images/navigation/Sentry_CustomerCare.jpg',
			                        '/images/navigation/Sentry_Faq-over.jpg','/images/navigation/Sentry_Faq.jpg',
			                        '/images/navigation/Sentry_GunSafes-over.jpg','/images/navigation/Sentry_GunSafes.jpg',
			                        '/images/navigation/Sentry_Header_Commitment.jpg','/images/navigation/Sentry_Header_Logo.jpg',
			                        '/images/navigation/Sentry_HomeSafes-over.jpg','/images/navigation/Sentry_HomeSafes.jpg',
			                        '/images/navigation/Sentry_NavSpacer.jpg','/images/navigation/Sentry_NavSpacer_Bottom.jpg',
			                        '/images/navigation/Sentry_OurHistory-over.jpg','/images/navigation/Sentry_OurHistory.jpg',
			                        '/images/navigation/Sentry_Products-over.jpg','/images/navigation/Sentry_Products.jpg',
			                        '/images/navigation/Sentry_PublicRelations-over.jpg','/images/navigation/Sentry_PublicRelations.jpg',
			                        '/images/navigation/Sentry_ReplacementParts-over.jpg','/images/navigation/Sentry_ReplacementParts.jpg',
			                        '/images/navigation/Sentry_SafeOfTheMonth.jpg',
			                        '/images/navigation/Sentry_TestingAndStandards-over.jpg','/images/navigation/Sentry_TestingAndStandards.jpg',
			                        '/images/navigation/Sentry_WarrentyRegistration-over.jpg','/images/navigation/Sentry_WarrentyRegistration.jpg',
			                        '/images/navigation/Sentry_WhereToBuy-over.jpg','/images/navigation/Sentry_WhereToBuy.jpg',
			                        '/images/navigation/Sentry_WhyChooseSentry-over.jpg','/images/navigation/Sentry_WhyChooseSentry.jpg',
			                        '/images/navigation/Sentry_WorkingHere-over.jpg','/images/navigation/Sentry_WorkingHere.jpg'
			                        );

			//don't touch this (it does the pre-loading for you)
			for(var i = 0; i < preLoad.length;i++){
					var k = new Image();
					k.src = preLoad[i];
			}
			
	}

	function rollover(){
			if(goodBrowser == 1){
					for(var i = 0; i < rollover.arguments.length; i += 2){
						//alert(rollover.arguments.length);
					document.images[rollover.arguments[i]].src = rollover.arguments[i+1];
					
					}
			}

	}


// ****************** DATE CODE ****************** //
	var _arrDays = new Array("Sunday", "Monday", "Tuesday",	"Wednesday", "Thursday", "Friday", "Saturday");

	var _arrMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	// getLongDate is in the following format: Thursday, January 2, 2003. 
		function getLongDate(date) {
			var strOutput;
			return _arrDays[date.getDay()] + ", " + _arrMonths[date.getMonth()] + " " + date.getDate () + ", " + getFullYear(date);
		}

	// getShortDate is in the following format: January 2, 2003. 
		function getShortDate(date) {
			var strOutput;
			return _arrMonths[date.getMonth()] + " " + date.getDate () + ", " + getFullYear(date);
		}

	// getIntlDate is in the following format: 2 January 2003.  This would be used mainly for international date formats.
		function getIntlDate(date) {
			var strOutput;
			return date.getDate () + " " + _arrMonths[date.getMonth()] + " " + getFullYear(date);
		}

	// getFullYear is in the following format: 2003 (displays the current year only).
		function getFullYear(date) {
			if (date.getYear() > 1900) {
				return date.getYear();
			} else {
				return date.getYear() + 1900;
			}
		}
	//extract the left part of the string
	function Left(str, n){
			if (n <= 0)
	    	return "";
			else if (n > String(str).length)
	    	return str;
			else
	    	return String(str).substring(0,n);
	}	
	
	
// ****************** DISPLAY SHIPPING INFORMATION FIELDS (for replacement keys) ****************** //
	 //hides shipping info fields 
	 function enableFields() {
	 document.personalInfo.x_ship_to_first_name.disabled=false;
	 document.personalInfo.x_ship_to_first_name.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_last_name.disabled=false;
	 document.personalInfo.x_ship_to_last_name.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_company.disabled=false;
	 document.personalInfo.x_ship_to_company.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_address.disabled=false;
	 document.personalInfo.x_ship_to_address.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_city.disabled=false;
	 document.personalInfo.x_ship_to_city.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_state.disabled=false;
	 document.personalInfo.x_ship_to_state.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_zip.disabled=false;
	 document.personalInfo.x_ship_to_zip.style.backgroundColor="#FFFFFF";
	 
	 document.personalInfo.x_ship_to_country.disabled=false;
	 document.personalInfo.x_ship_to_country.style.backgroundColor="#FFFFFF";
	 }
	 
	 //displays shipping info fields 
	 function disableFields() {
	 document.personalInfo.x_ship_to_first_name.disabled=true;
	 document.personalInfo.x_ship_to_first_name.style.backgroundColor="#CCCCCC";
	 
	 document.personalInfo.x_ship_to_last_name.disabled=true;
	 document.personalInfo.x_ship_to_last_name.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_company.disabled=true;
	 document.personalInfo.x_ship_to_company.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_address.disabled=true;
	 document.personalInfo.x_ship_to_address.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_city.disabled=true;
	 document.personalInfo.x_ship_to_city.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_state.disabled=true;
	 document.personalInfo.x_ship_to_state.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_zip.disabled=true;
	 document.personalInfo.x_ship_to_zip.style.backgroundColor="#CCCCCC";	 
	 
	 document.personalInfo.x_ship_to_country.disabled=true;
	 document.personalInfo.x_ship_to_country.style.backgroundColor="#CCCCCC";
	 }

	 // ****************** product codes for key replacement ****************** //
	 // these must have a lock number entered
   var _arrNeedLockNum = new Array("1100", "1100B", "1100G", "1100N", "1100S", "1110", "2100", "2110", "2500", "KS2100", "KS4100", "1120", "1150", "1160", "1950", "2150", "2460", "KS100", "1170", "1175", "1180", "1190", "2170", "2175", "2180", "2190", "2275", "2370", "2375", "2475", "2570", "6000", "1710", "6720", "1800", "1900", "1970", "1860", "1870", "U1401", "U2101", "U2401", "E1000", "CB-10", "CB-10R", "CB-12", "CB-14", "CB-8", "CB8", "DCB-1", "DCB1", "DS-1", "FCB-1", "KB-25", "KB-50", "LPCB-1", "SCB-12", "1000", "1750", "2000", "2001", "2300", "2360", "7100", "H2100", "H4300", "H2300", "H3100", "H3300", "F2300", "F3300", "H4100");
   
	 // these must have a serial number entered
	 var _arrNeedSerialNum = new Array("A3410", "A3421", "A3427", "A3431", "A3450", "A3460", "A3750", "A3800", "A3807", "A3810", "A3817", "A3819", "A3820", "A3821", "A3827", "A3850", "A3860", "A3867", "A3871", "I0000", "I0090", "I0300", "I3390", "I3700", "I3790", "J3000", "J3090", "J3700", "J3790", "L0410", "L0810", "L3469", "L3869", "S0300", "S0310", "S0320", "S0400", "S0407", "S0407M", "S0409", "S0410", "S0417", "S0420", "S0470", "S0490", "S0491", "S0496", "S0807", "S0810", "S0891", "S0896", "S0899", "S3310", "S3400", "S34407", "S3410", "S3417", "S3420", "S3421",
	                                    "S3460", "S3467", "S3468", "S3470", "S3471", "S3710", "S3740", "S3803", "S3807", "S3810", "S3817", "S3821", "S3827", "S3860", "S3861", "S3870", "S3871", "S3877", "S5810", "SC3877", "A4310", "A4381", "A4487", "A4835", "A4849", "A4881", "A4887", "A5381", "A5460", "A5489", "A5781", "A5835", "A5845", "A5846", "A5848", "A5860", "A5865", "A5867", "A5882", "A5889", "S4360", "S4370", "S4381", "S5149", "S5381", "S5481", "S5741", "S5848", "S5855", "S6370", "S6520", "S6530", "S6570", "S6770", "S7371", "S7771", "S8371", "S8771", "7150", "7250",
																			"2200", "2205", "2206", "2230", "2235", "2236", "2260", "2280", "2286", "7201", "X0300", "X3300", "X3700", "Z3700");
	 
	 	function checkLockNum(aform)
		{
			for (var i=0; i< _arrNeedLockNum.length; i++) {
					if  ( aform.f_model.value.toUpperCase() == _arrNeedLockNum[i] )
					{
					 return true; //needs a lock
					}
		  }
		}
		
		//checks to see if you need a serial or not
		function checkSerialNum(aform)
		{

			for (var i=0; i< _arrNeedSerialNum.length; i++) {
					if  ( aform.f_model.value.toUpperCase() == _arrNeedSerialNum[i] )
					{
					 return true; //need a serial
					}
		  }
		}
function Mod10(ccno) {
	vlengthgood=0;
	ccsum=0;
	cclen=ccno.length;
	if (cclen<13)
	{
		alert("Credit cards must have at least 13 digits.");
	}
	else
	{
		for (i=1; i<cclen; i++)
		{
			ccdig=parseInt(ccno.charAt(cclen-(i+1)));
			if (i%2==1)
			{
				ccdig*=2;
				if (ccdig.toString().length==2)
				{
					ccdig=(parseInt(ccdig.toString().charAt(0))+parseInt(ccdig.toString().charAt(1)));
				} 
			}
			ccsum+=ccdig;
		}
		ccsum+=parseInt(ccno.charAt(cclen-1));
		if (ccsum%10==0)
		{
			//document.forms[0].cardrslt.value="Mod10 PASSED";

				cc_type_id = 'NOT VALID TYPE';
			if (ccno.match(/^4/) )
				{cc_type_id = 'VISA';   if (cclen==13 || cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^50|^56|^57|^58|^6/) )
				{cc_type_id = 'MAESTRO';   vlengthgood=1;}
			if (ccno.match(/^51|^52|^53|^54|^55/) )
				{cc_type_id = 'MASTERCARD';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^413733|^413734|^413735|^413736|^413737|^4462|^453978|^453979|^454313|^454313|^454432|^454433|^454434|^454435|^454742|^456725|^456726|^456727|^456728|^456729|^45673|^456740|^456741|^456742|^456743|^456744|^456745|^46583|^46584|^46585|^46586|^46587|^484409|^484410|^49096|^49097|^492181|^492182|^498824/) )
				{cc_type_id = 'DELTA';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^450875|^484406|^484407|^484408|^484411|^484412|^484413|^484414|^484415|^484416|^484417|^484418|^484419|^48442|^48443|^48444|^484450|^484451|^484452|^484453|^484454|^484455|^49173|^49174|^49175|^491880/) )
				{cc_type_id = 'ELECTRON';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^405501|^405502|^405503|^405504|^405550|^405551|^405552|^405553|^405554|^415928|^424604|^424604|^427533|^4288|^443085|^4484|^4485|^4486|^4715|^4716|^4804/) )
				{cc_type_id = 'VISA PURCHASING';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^490300|^490301|^49031|^49032|^490330|^490331|^490332|^490333|^490334|^49034|^49035|^49036|^49037|^49038|^49039|^49040|^490419|^490451|^490459|^490467|^490475|^490476|^490477|^490478|^4905|^491103|^491104|^491105|^491106|^491107|^491108|^491109|^49111|^49112|^49113|^49114|^49115|^49116|^491170|^491171|^491172|^491173|^491183|^491184|^491185|^491186|^491187|^491188|^491189|^49119|^4928|^4987/) )
				{cc_type_id = 'VISA_ATM';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^60/) )
				{cc_type_id = 'DISCOVER';   if (cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^63345|^63346|^63347|^63348|^63349|^6767/) )
				{cc_type_id = 'SOLO';   if (cclen==16 || cclen==18 || cclen==19) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^490302|^490303|^490304|^490305|^490306|^490307|^490308|^490309|^490335|^490336|^490337|^490338|^490339|^491101|^491102|^491174|^491175|^491176|^491177|^491178|^491179|^491180|^491181|^491182|^4936|^564182|^63330|^63331|^63332|^63333|^63334|^6759/) )
				{cc_type_id = 'SWITCH';   if (cclen==16 || cclen==18 || cclen==19) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^34|^37/) )
				{cc_type_id = 'AMEX';   if (cclen==13 || cclen==15) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^3528|^3529|^353|^354|^355|^356|^357|^358|^2131|^1800/) )
				{cc_type_id = 'JCB';   if (cclen==15 || cclen==16) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^300|^301|^302|^303|^304|^305|^36|^380|^381|^382|^383|^384|^385|^386|^387|^388/) )
				{cc_type_id = 'DINERS CLUB';   if (cclen==14) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^389/) )
				{cc_type_id = 'CARTE BLANCHE';   if (cclen==14) {vlengthgood=1;}   else {vlengthgood=0;} }
			if (ccno.match(/^2014|^2149/) )
				{cc_type_id = 'ENROUTE';   if (cclen==15) {vlengthgood=1;}   else {vlengthgood=0;} }

			//document.forms[0].checksum.value=ccsum;
			//document.forms[0].cclength.value=cclen;

			if (vlengthgood==1) 
				{
				//document.forms[0].cardtype.value=cc_type_id;
				}
			else
				{
				//document.forms[0].cardrslt.value="BAD LENGTH";
				alert("Card is Invalid Please Try Again");
				//document.forms[0].cardtype.value="BAD CARD";
				}
		} 
		else
		{
			alert("Card is Invalid Please Try Again (Mod 10 Failed)");
			//document.forms[0].cardrslt.value="Mod10 FAILED";
			//document.forms[0].checksum.value=ccsum;
			//document.forms[0].cclength.value=cclen;
			//document.forms[0].cardtype.value="";
		}
	}	
}
function ClearC()
{
	//document.forms[0].cardrslt.value="";
	//document.forms[0].cardno.value="";
	//document.forms[0].cardtype.value="";
	//document.forms[0].checksum.value="";
	//document.forms[0].cclength.value="";
}






		
		