 var locations = new Array(15);locations['3'] = new Array("3", "33.8045950", "-84.4372920", "279.37", "3.24", "", "33.804513", "-84.437005", "Champion Self Storage", "Atlanta", "1820 Marietta Blvd. NW Atlanta, GA 30318", "404-351-5551", "678-894-7886", "Heading I-75 N. Take exit 252B for Howell Mill Rd. Turn left at Howell Mill Rd NW. Turn right at Chattahoochee Ave NW. Turn left at Carroll Dr NW. Turn right at Marietta Blvd NW. Store located .2 miles on left.", "Heading I-75 / I-85 North. Take exit 249D toward Georgia Tech/US-78/US-278/N Ave. Merge onto Williams St NW. Turn right at N Ave NW. Turn left at Northside Dr NW. Turn right at Simpson St NW. Turn right at Joseph E Lowery Blvd NW. Turn left at Bankhead Hwy NW/Donald Lee Hollowell Pkwy NW. Turn right at Marietta Blvd NW on Left 2.5 Miles.", "Heading I-85 S. Take exit 85 to merge onto I-75 N. Take exit 252B for Howell Mill Rd. Turn left at Howell Mill Rd NW. Turn right at Chattahoochee Ave NW. Turn left at Carroll Dr NW. Turn right at Marietta Blvd NW .2 miles on left.", "Heading I-285 W toward Chattanooga/Birmingham. Take exit 16 for S Atlanta Rd toward Smyrna. Turn left at Atlanta Rd SE. Continue on Marietta Blvd NW. Store is 1.9 Miles on Right.", "GA", "Georgia", "30318", "1820", "Marietta Blvd. NW"); locations['15'] = new Array("15", "26.639435", " -82.028463", "1.82", "2.6", "1", "26.637464", "-82.02845", "Champion Self Storage", "Cape Coral", "2607 SW Pine Island Rd. Cape Coral, FL 33991", "239-282-2866", "239-677-4633", "", "", "", "", "FL", "Florida", "33991", "2607", "SW Pine Island Rd."); locations['1'] = new Array("1", "33.88764218267927", " -83.94641250371933", "-132.1", "8.6528", "", "33.887635", "-83.946354", "Champion Self Storage", "Grayson", "2415 Loganville Hwy SW Grayson, GA 30017", "678-407-0347", "678-829-0229", "North on GA 13 (N Buford Hwy) toward Sydney Marcus Blvd Turn Right on Lenox Rd N.E To Chesire Bridge Rd N.E. merge I-85 North,via ramp left toward Greenville,Keep right to 316 east toward Lawrenceville / Athens, Exit @ Sugarloaf Pky, Right on Sugarloaf Pkwy, Right on Grayson Hwy SW (GA 20) property is two miles on right.", "Stone Mtn. - Memorial Drive east to Cynthia Mckinney Pkwy, continue to follow GA10 East Hwy 78 East onto Grayson Pkwy, Right onto Hwy 20 (Loganville Hwy) Approx. 2 miles on the right.", "Turner Hill Road ( GA-124 North ) to Hwy 78 Right on 78 to Grayson Pkwy, to Hwy 20 (Loganville Hwy) 2 miles on right.", "I-85 North to GA-403 North, I-28 Bypass going East, Take Exit 68 towards Macon / Augusta, Merge on I-285 East, to GA-10 East, Exit onto 41, Turn right, on memorial drive and continue Hwy 78 to grayson hwy, left on Grayson Hwy to Hwy 20 turn right, Property is two miles on right.", "GA", "Georgia", "30017", "2415", "Loganville Hwy SW"); locations['13'] = new Array("13", "30.1935805", "-81.7977469", "119.06", "2.6", "0", "30.193258", "-81.79793", "Champion Self Storage", "Jacksonville", "8421 Cheswick Oak Rd. Jacksonville, FL 32244", "904-777-8333", "904-677-8909", "Go south on 295 to exit 12 (Blanding Blvd), at the red light going west go to 2 more red lights at that time you will make a right on Argyle Forest Blvd going 3- 1/2 miles to red light that is Cheswick Oaks Avenue,  McDonalds is on the left side of the light you make a left  there and go to the second drive way.", "Go North on 295 to exit 12 (Blanding Blvd.), at the red light make a left  going west to the third red light, Argyle Forest Blvd make a right go 3 -1/2 miles north to red light that is Cheswick Oaks Avenue. McDonalds is on the left side of the light turn left and go to the second drive way.", "Go to Blanding Blvd. east toward Orange Park go under St Rd 295 underpass 3rd light beyond is Argyle Forest Blvd turn right go 3 ? &amp;#65533; miles north to red light Cheswick Oaks Avenue, McDonalds is on the left side of the light turn left and go to the second driveway.", "Go east on Blanding Blvd through Orange park after you pass the Orange Park Mall, Wells Road you go to the next red light Argyle Forest Blvd. make a left go 3 -1/2 miles north to red light Cheswick Oaks Avenue, McDonalds is on the left turn left and go to the second drive way.", "FL", "Florida", "32244", "8421", "Cheswick Oak Rd."); locations['6'] = new Array("6", "28.2946810", "-81.3707150", "226.995", "4.888", "1", "28.296117", "-81.369046", "Champion Self Storage", "Kissimmee", "1830 E Irlo Bronson Memorial Hwy Kissimmee, FL 34744", "407-343-9384", "407-624-4506", "Take Turnpike South and take Exit 244 Kissimmee/St. Cloud. Right onto Highway 192, Facility is 2 mile down on the left.", "John Young Parkway North to highway 192. Right onto 192, facility is 3 miles down on the right hand side.", "From Saint Cloud take highway 192 , pass the Turnpike exit the facility is 1 mile down on the left hand side.", "Take N Orange Blossom/ US-441 S. 1.3 miles. Turn Sight right onto N John Young PKWY / Fl-423 S, Continue to follow it 21 miles. Turn left onto 192 and follow 3 miles and the facility is on the right hand side.", "FL", "Florida", "34744", "1830", "E Irlo Bronson Memorial Hwy"); locations['16'] = new Array("16", "25.5023200", "-80.4440510", "-56.04", "7.821", "", "", "", "Champion Self Storage", "Leisure City", "28525 SW 157th Ave. Leisure City, FL 33031", "305-246-8115", "786-377-3960", "", "", "", "", "FL", "Florida", "33031", "28525", "SW 157th Ave."); locations['14'] = new Array("14", "27.9119790", "-81.9769210", "17.45", "13.63", "", "27.911312", "-81.975877", "Champion Self Storage", "Mulberry", "3000 Mulford Rd. Mulberry, FL 33860", "863-425-5814", "863-774-3132", "I-4 to S. Florida Ave.  2 miles past Shepherd Rd.  Turn right on Mulford Road at Mulberry Post Office.", "N. Florida Ave. across Hwy 60, 2 miles, turn left on Mulford Road at Mulberry Post Office.", "Hwy 60 W. to Hwy 37, turn right, 2 miles, turn left on Mulford Road at Mulberry Post Office.", "Hwy 60 E. to Hwy 37, turn left, 2 miles, turn left on Mulford Road at Mulberry Post Office.", "FL", "Florida", "33860", "3000", "Mulford Rd."); locations['2'] = new Array("2", "33.9636188", "-84.2035552", "-211.2276", ".2644", "", "", "", "Champion Self Storage", "Norcross", "5180 Peachtree Industrial Blvd Norcross, GA 30071", "770-416-8330", "678-444-4792", "Going I-85 South to I-285 West exit 31B to merge onto GA-141 / Peachtree Indusrial Blvd. Arrive @ 5180 Peachtree Industrial Blvd on Right", "Going I-85 North to I-285 West exit 31B to merge onto GA-141 / Peachtree Indusrial Blvd. Arrive @ 5180 Peachtree Industrial Blvd on Right", "Going I-85 South to I-285 West exit 31B to merge onto GA-141 / Peachtree Indusrial Blvd. Arrive @ 5180 Peachtree Industrial Blvd on Right", "Going I-85 North to I-285 West exit 31B to merge onto GA-141 / Peachtree Indusrial Blvd. Arrive @ 5180 Peachtree Industrial Blvd on Right 6.6 miles from I-285", "GA", "Georgia", "30071", "5180", "Peachtree Industrial Blvd"); locations['4'] = new Array("4", "28.6088750", "-81.4505780", "91.8", "5.16", "", "28.608795", "-81.451692", "Champion Self Storage", "Orlando", "5301 N. Pine Hills Rd. Orlando, FL 32808", "407-522-0941", "407-641-0275", "From I-4 exit on Maitland Blvd heading Westbound to 441 N Orange Blossom Trail and make a left going South. Follow 441 until Clarcona-Ocoee and make a right. Follow the road until Pine Hills Road and make a left at the light and it is less than a block down on the left.", "From the 408 East-West Expressway exit on Pine Hills Road heading Northbound until you reach us right before Clarcona-Ocoee.", "Exit off I-4 onto Lee Road heading westbound until you reach 441 North Orange Blossom Trail and make  a right on 441 heading Northbound. Then turn left onto Clarcona-Ocoee and follow it until you reach Pine Hills Road and make another left and its less than a block down on the left.", "Take the Florida turnpike to the 408 East-West Expressway. From the 408 East-West Expressway exit on Pine Hills Road heading Northbound until you reach us right before Clarcona-Ocoee.", "FL", "Florida", "32808", "5301", "N. Pine Hills Rd."); locations['5'] = new Array("5", "28.6232160", "-81.4505910", "164.25022", "3.406", "", "28.623634", "-81.450315", "Champion Self Storage", "Orlando", "7244 Overland Rd Orlando, FL 32810", "407-295-6580", "407-641-0280", "Heading South on 441 Orange Blossom Trail from Apopka go past Super Center Walmart on right, then pass the 414 Maitland Exchange on left and go 1 mile to top of hill and turn right on Overland Road.  Go 1/3 mile to Champion Self Storage on left.", "Heading North from Orlando on 441 Orange Blossom Trail go past Lee Road, go past Clarcona Ocoee Road go through Lockhart.  Go through green light at Rose Avenue and turn left on Overland Road only 75 yards.  Go 1/3 mile to Champion Self Storage on left.", "Heading West on I-4 from Daytona ?pass the 436 Altamonte Springs exit entering Orlando-Next Exit is the 414 Maitland Exchange-Exit Right and stay on 414 till dead end at 441 Orange Blossom Trail.  Turn left and go 1 mile and turn Right at Overland Road at top of hill.  Go 1/3 mile to Champion Self Storage on left.", "Heading East on Highway 50 coming into Orlando turn left or North on Pine Hills Road.  Cross over Silver Star and Clarcona Ocoee Road.  Go 1 mile and turn right on Overland Road go 100 yards and Champion Self Storage on right.", "FL", "Florida", "32810", "7244", "Overland Rd"); locations['12'] = new Array("12", "29.662522", "-81.681504", "", "", "", "", "", "Champion Self Storage", "Palatka", "4001 Reid St. Palatka, FL 32177", "386-325-2046", "386-530-4106", "Going south on Route 19 at the red light at Route 100 (Reid Street) make a right heading west. Go one mile to the 2nd light and make a &quot;U&quot; turn, we set 50 feet on the south side of the road.", "Going North on Route 19 at the red light at Route. 100 (Reid Street) make a left, heading west. Go one mile to the 2nd light and make a &quot;U&quot; turn, we set 50 feet on the south side of the road.", "Going east on Route 100 (Reid Street) at the intersection of 100 and 216 go 50 feet further east. We set on the south side of the road.", "Going west on Route 100 (Reid Street) after you pass Route 19, Go one mile to the 2nd light and make a &quot;U&quot; turn, we set 50 feet on the south side of the road.", "FL", "Florida", "32177", "4001", "Reid St."); locations['10'] = new Array("10", "29.55595036978796", " -81.2563043832779", "-444.3312", "-2.25", "", "29.556017", "-81.256287", "Champion Self Storage", "Palm Coast", "11 Pine Lakes Parkway N. Palm Coast, FL 32137", "386-446-8533", "386-530-4721", "", "", "", "", "FL", "Florida", "32137", "11", "Pine Lakes Parkway N."); locations['11'] = new Array("11", "29.5478840", "-81.2254210", "154.13", "3.08", "", "29.549694", "-81.227612", "Champion Self Storage", "Palm Coast", "531 Cypress Edge Dr. Palm Coast, FL 32164", "386-445-5122", "386-530-4719", "Take exit 289 then right onto Palm Coast Pkwy. Take 1st left onto Cypress Point. Take another left onto Cypress Edge. Facility on right.", "Take 95 to exit 289. Turn left onto Palm Coast Pkwy, then left onto Cypress Point. Take another left onto Cypress Edge. Facility on Right.", "Take Palm Coast Pwky west then left onto Cypress Point then another left onto Cypress Edge. Facility on right.", "Take Palm Coast Pkwy East to Cypress Point. Take a Right onto Cypress Point then a left onto Cypress Edge. Facility on right.", "FL", "Florida", "32164", "531", "Cypress Edge Dr."); locations['7'] = new Array("7", "27.71293346686642", " -82.39561021327972", "-152.229823", "-3.66079", "", "27.712958", "-82.395631", "Champion Self Storage", "Ruskin", "2809 East College Ave. Ruskin, FL 33570", "813-641-1777", "813-200-6963", "I 75 south to exit 240 B.  Go west on SR 674 approx 1/2 mile, Champion Self Storage is on the left.", "I 75 north to the Sun City Center exit 240 stay left and turn left ( West) on SR 674 for approx 3/4 mile Champion Self Storage is on the left.", "From Hwy 301 go West on SR 674 approx 5 1/2 miles Champion Self Storage is on the left.", "From Hwy 41 go East on SR 674 approx 2 1/2 miles Champion Self Storage is on the right. ", "FL", "Florida", "33570", "2809", "East College Ave."); locations['17'] = new Array("17", "41.4909310", "-87.4776510", "-357.83958", "2.87473", "", "41.490742", "-87.477822", "Champion Self Storage", "Schererville", "1104 W Lincoln Hwy Schererville, IN 46375", "219-322-7236", "219-227-6064", "", "", "", "", "IN", "Indiana", "46375", "1104", "W Lincoln Hwy"); 

var facilities = new Array(3,15,1,13,6,16,14,2,4,5,12,10,11,7,17)



//MAP//////////////

var directionDisplay;
  var directionsService = new google.maps.DirectionsService();
  var markersArray = [];
  var latlng; 
  var map;
  var trafficLayer;
  var bounds = new google.maps.LatLngBounds();
  var infowindow = new google.maps.InfoWindow();

  
   
  
  function createMarker(page, id) {
  
  	var contentString = "<h3>"+ locations[id][8] +" - "+ locations[id][9] +"</h3>";
	contentString += '<img src="/images/gallery/'+ locations[id][0] +'/pic1.jpg" alt="'+ locations[id][8] +' - '+ locations[id][9] +' '+ locations[id][17] +'" width="100" border="1" style="float:left; margin-right: 13px;"/>';
	contentString += locations[id][20] +' '+locations[id][21]+'<br/>'+locations[id][9]+', '+locations[id][17]+'<br/>';
	contentString += ((locations[id][12] !== "--" ) ? locations[id][12] : locations[id][11]) +'<br/>'
	
	contentString += '<a href="/'+locations[id][9].replace(" ", "-")+'-'+locations[id][18]+'/'+locations[id][19]+'/'+locations[id][0]+'">More Information</a>';
	


	var position = new google.maps.LatLng(locations[id][1], locations[id][2])
    var marker = new google.maps.Marker({
        position: position,
        map: map,
        title: locations[id][8],
		icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld=C%7C1f712f%7C000000'
    });
	
	/*var infowindow = new google.maps.InfoWindow({
        content: contentString
    });*/
    if (page != 'facility') { google.maps.event.addListener(marker, 'click', function() {
        infowindow.close()
		infowindow.setContent(contentString);
		infowindow.open(map, marker);

    }); }
	markersArray.push(marker);
	bounds.extend(position)
	//alert (id + locations[id])
}
  
  
  function initialize(page, id, state) {
  
    if (id) { latlng = new google.maps.LatLng(locations[id][1], locations[id][2]); }
	else { latlng = new google.maps.LatLng(0,0) } 
    var myOptions = {
      zoom: 15,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	directionsDisplay = new google.maps.DirectionsRenderer();
	directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));
	
	if (id) {
		createMarker(page, id)
	} else {
		
		for (var i=0; i<facilities.length; i++) {
			
			if (state == locations[facilities[i]][18]) {
				createMarker(page, facilities[i])
			}
			
			if (page == 'all_locations') {
				createMarker(page, facilities[i])
			}
			
		}
		map.fitBounds(bounds);
	}

	

	if (id) {
	 // We get the map's default panorama and set up some defaults.
    // Note that we don't yet set it visible.
    panorama = map.getStreetView();
    panorama.setPosition(((locations[id][6]) ? new google.maps.LatLng(locations[id][6], locations[id][7]) : latlng));
	

    panorama.setPov({
      heading: ((locations[id][3]) ? parseFloat(locations[id][3]) : 16.5), 
      zoom: ((locations[id][5]) ? parseFloat(locations[id][5]) : 0),
      pitch: ((locations[id][4]) ? parseFloat(locations[id][4]) : 7.658284707444938)} //
    );
	
	}
	
   trafficLayer = new google.maps.TrafficLayer();
  
	/*
	google.maps.event.addListener(panorama, 'pov_changed', function() {
	document.getElementById("directionsPanel").innerHTML =  panorama.getPosition()+' '+panorama.getPov().heading +' '+ panorama.getPov().pitch
	
    }); */
	
	
if (page == 'state_locations' || page == 'all_locations') {} else {
// Create the DIV to hold the control and
  // call the HomeControl() constructor passing
  // in this DIV.
  var streetControlDiv = document.createElement('DIV');
  var streetControl = new StreetControl(streetControlDiv, map);

  streetControlDiv.index = 1;
  map.controls[google.maps.ControlPosition.TOP_RIGHT].push(streetControlDiv);
  
  }
		if (page != 'facility') {
	// Create the DIV to hold the control and
  // call the HomeControl() constructor passing
  // in this DIV.
  var trafficControlDiv = document.createElement('DIV');
  var trafficControl = new TrafficControl(trafficControlDiv, map);

  trafficControlDiv.index = 1;
  map.controls[google.maps.ControlPosition.TOP_RIGHT].push(trafficControlDiv);
	
  
	
	// Create the DIV to hold the control and
  // call the HomeControl() constructor passing
  // in this DIV.
  var homeControlDiv = document.createElement('DIV');
  var homeControl = new HomeControl(homeControlDiv, map);

  homeControlDiv.index = 1;
  map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
	
	}

  
  
  }
  var traffic_state = 0;
  
  function toggleTraffic() {
	if (traffic_state == 0) {
		trafficLayer.setMap(map);
		traffic_state = 1;
	} else {
		trafficLayer.setMap(null);
		traffic_state = 0;
	}
  }
  
   function toggleStreetView() {
    var toggle = panorama.getVisible();
    if (toggle == false) {
      panorama.setVisible(true);
    } else {
      panorama.setVisible(false);
    }
  }
  
  function calcRoute(start, id) {
    var end = locations[id][10];
    var start = start;
    var request = {
        origin:start, 
        destination:end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
	    document.getElementById("directionsPanel").innerHTML = '';
        directionsDisplay.setDirections(response);
		 directionsDisplay.setMap(map);
		 if (markersArray) {
			for(i in markersArray) {
				markersArray[i].setMap(null);
			}
		 }
      }
    });
  return false;
  }
  
  function clearDirections(id) { 
	directionsDisplay.setMap(null);
	
	if (markersArray) {
		for(i in markersArray) {
			markersArray[i].setMap(map);
		}
	}
	document.getElementById("directionsPanel").innerHTML = '';
	document.getElementById("directionsPanel").innerHTML = '<table cellpadding="5">' + 
	
	// 13 14 15 16
	
	((locations[id][13]) ? '<tr><td><b><span class="directions">From the North:</span></b> '+ locations[id][13] +'</td></tr>' : '') +
	((locations[id][14]) ? '<tr><td><b><span class="directions">From the South:</span></b> '+ locations[id][14] +'</td></tr>' : '') +
	((locations[id][15]) ? '<tr><td><b><span class="directions">From the East:</span></b> '+ locations[id][15] +'</td></tr>' : '') +
	((locations[id][16]) ? '<tr><td><b><span class="directions">From the West:</span></b> '+ locations[id][16] +'</td></tr>' : '') +
	
	
	'</table>';
	
	
	

  }
  
function HomeControl(controlDiv, map) {

  // Set CSS styles for the DIV containing the control
  // Setting padding to 5 px will offset the control
  // from the edge of the map
  controlDiv.style.padding = '5px';

  // Set CSS for the control border
  var controlUI = document.createElement('DIV');
  controlUI.style.backgroundColor = 'white';
  controlUI.style.borderStyle = 'solid';
  controlUI.style.borderWidth = '2px';
  controlUI.style.cursor = 'pointer';
  controlUI.style.textAlign = 'center';
  controlUI.title = 'Reset Map';
  controlDiv.appendChild(controlUI);

  // Set CSS for the control interior
  var controlText = document.createElement('DIV');
  controlText.style.fontFamily = 'Arial,sans-serif';
  controlText.style.fontSize = '12px';
  controlText.style.paddingLeft = '4px';
  controlText.style.paddingRight = '4px';
  controlText.innerHTML = 'Reset';
  controlUI.appendChild(controlText);

  // Setup the click event listeners: simply set the map to

  google.maps.event.addDomListener(controlUI, 'click', function() { map.setCenter(latlng); map.setZoom(15) } );
}
  
  function StreetControl(controlDiv, map) {

  // Set CSS styles for the DIV containing the control
  // Setting padding to 5 px will offset the control
  // from the edge of the map
  controlDiv.style.padding = '5px';

  // Set CSS for the control border
  var controlUI = document.createElement('DIV');
  controlUI.style.backgroundColor = 'white';
  controlUI.style.borderStyle = 'solid';
  controlUI.style.borderWidth = '2px';
  controlUI.style.cursor = 'pointer';
  controlUI.style.textAlign = 'center';
  controlUI.title = 'Street View';
  controlDiv.appendChild(controlUI);

  // Set CSS for the control interior
  var controlText = document.createElement('DIV');
  controlText.style.fontFamily = 'Arial,sans-serif';
  controlText.style.fontSize = '12px';
  controlText.style.paddingLeft = '4px';
  controlText.style.paddingRight = '4px';
  controlText.innerHTML = 'Street View';
  controlUI.appendChild(controlText);

  // Setup the click event listeners: simply set the map to

  google.maps.event.addDomListener(controlUI, 'click', function() { toggleStreetView(); } );
}
  
function TrafficControl(controlDiv, map) {

  // Set CSS styles for the DIV containing the control
  // Setting padding to 5 px will offset the control
  // from the edge of the map
  controlDiv.style.padding = '5px';

  // Set CSS for the control border
  var controlUI = document.createElement('DIV');
  controlUI.style.backgroundColor = 'white';
  controlUI.style.borderStyle = 'solid';
  controlUI.style.borderWidth = '2px';
  controlUI.style.cursor = 'pointer';
  controlUI.style.textAlign = 'center';
  controlUI.title = 'Traffic';
  controlDiv.appendChild(controlUI);

  // Set CSS for the control interior
  var controlText = document.createElement('DIV');
  controlText.style.fontFamily = 'Arial,sans-serif';
  controlText.style.fontSize = '12px';
  controlText.style.paddingLeft = '4px';
  controlText.style.paddingRight = '4px';
  controlText.innerHTML = 'Traffic';
  controlUI.appendChild(controlText);

  // Setup the click event listeners: simply set the map to

  google.maps.event.addDomListener(controlUI, 'click', function() { toggleTraffic() } );
}

function myclick(i) {
	
		google.maps.event.trigger(markersArray[i], "click");
	
}





// SLIDESHOW ////////////////

var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 2000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed = 10;	// Speed of fading	(Lower value = faster)


var slideshow2_stats = new Array();

var slideshow2_slideIndex = new Array();	// Index of current image shown
var slideshow2_slideIndexNext = new Array();	// Index of next image shown
var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity = new Array();	// Initial opacity
var slideshow2_imagesInGallery = new Array();	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs(imageIndex,divId)
{
	if(imageIndex==slideshow2_imagesInGallery[divId]){	
		showGallery(divId);
	}else{
		var imgObj = document.getElementById(divId + '_' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		if(!slideshow2_imageDivs[divId])slideshow2_imageDivs[divId] = new Array();
		slideshow2_imageDivs[divId][slideshow2_imageDivs[divId].length] =  imgObj;

		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs(imageIndex,divId);	
	}		
}

function showGallery(divId)
{
	if(slideshow2_slideIndex[divId]==-1)slideshow2_slideIndex[divId]=0; else slideshow2_slideIndex[divId]++;	// Index of next image to show
	if(slideshow2_slideIndex[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndex[divId]=0;
	slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]+1;	// Index of the next next image
	if(slideshow2_slideIndexNext[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndexNext[divId] = 0;

	
	slideshow2_currentOpacity[divId]=100;	// Reset current opacity

	// Displaying image divs
	slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity=1)';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = 0.01;
	}		
	

	setTimeout('revealImage("' + divId + '")',slideshow2_timeBetweenSlides);		
}

function revealImage(divId)
{

	if(slideshow2_noFading){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';
		showGallery(divId);
		return;
	}
	slideshow2_currentOpacity[divId]--;
	if(document.all){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity[divId]+')';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity[divId])+')';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity[divId]/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity[divId]/100)));
	}
	if(slideshow2_currentOpacity[divId]>0){
		setTimeout('revealImage("' + divId + '")',slideshow2_fadingSpeed);
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';		
		showGallery(divId);
	}
}

function initImageGallery(divId)
{
	var slideshow2_galleryContainer = document.getElementById(divId);
	
	
	slideshow2_slideIndex[divId] = -1;
	slideshow2_slideIndexNext[divId] = false;
	
	var galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
	for(var no=0;no<galleryImgArray.length;no++){
		galleryImgArray[no].id = divId + '_' + no;
	}
	
	slideshow2_imagesInGallery[divId] = galleryImgArray.length;
	createParentDivs(0,divId);		
	
}





////// COUPON ///////////////////////

function func_coupon (id) {

	window.open("/coupon/"+id,"coupon","menubar=no,width=630,height=610,toolbar=no,scrollbars=no");

}





function GetXmlHttpObject2()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function stateChanged2() 
{ 
if (xmlHttp.readyState==4)
{ 

}
}

function print_coupon(str,location)
{

xmlHttp=GetXmlHttpObject2();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="templates/1/coupon_print.php";
url=url+"?barcode="+str;
url=url+"&location="+location;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
window.print();
}




// AJAX UNIT SIZES /////////////////////////////

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("cs_units").innerHTML=xmlHttp.responseText;
}
}

function showUnits(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/templates/1/unit_sizes.php";
url=url+"?id="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


/// NEW DROP DOWN MENU//////////////////////////////////////////////////

// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}



function addEvents() {
//onmouseover="mcancelclosetime()" onmouseout="mclosetime()
document.getElementById("m1").onmouseover = mcancelclosetime;
document.getElementById("m1").onmouseout = mclosetime;


document.getElementById("state1").onmouseover = function() {
document.getElementById("FL").style.visibility='visible';
document.getElementById("state1").style.backgroundColor='yellow';
}
document.getElementById("state1").onmouseout = function() {
document.getElementById("FL").style.visibility='hidden';
document.getElementById("state1").style.backgroundColor='#1F712F';
}

document.getElementById("FL").onmouseover = function() {
document.getElementById("FL").style.visibility='visible';
}
document.getElementById("FL").onmouseout = function() {
document.getElementById("FL").style.visibility='hidden';
}



document.getElementById("state2").onmouseover = function() {
document.getElementById("GA").style.visibility='visible';
document.getElementById("state2").style.backgroundColor='yellow';
}
document.getElementById("state2").onmouseout = function() {
document.getElementById("GA").style.visibility='hidden';
document.getElementById("state2").style.backgroundColor='#1F712F';
}

document.getElementById("GA").onmouseover = function() {
document.getElementById("GA").style.visibility='visible';
}
document.getElementById("GA").onmouseout = function() {
document.getElementById("GA").style.visibility='hidden';
}



document.getElementById("state3").onmouseover = function() {
document.getElementById("IN").style.visibility='visible';
document.getElementById("state3").style.backgroundColor='yellow';
}
document.getElementById("state3").onmouseout = function() {
document.getElementById("IN").style.visibility='hidden';
document.getElementById("state3").style.backgroundColor='#1F712F';
}

document.getElementById("IN").onmouseover = function() {
document.getElementById("IN").style.visibility='visible';
}
document.getElementById("IN").onmouseout = function() {
document.getElementById("IN").style.visibility='hidden';
}



}



var ann
var aState = 0;
var height = '154';
 
function a_set() {
ann = document.getElementById('a_content');
/*height = ann.clientHeight;*/
ann.style.height = '0px'
/*ann.style.visibility = 'hidden';*/

}

function a_display() {

	for (  ; ; ) { 
	
	if (aState == 1) {
		/*alert (height);*/
		
		for (var i=height; i >0; i--) {
			var t =setTimeout("a_extend("+i+")", 400-i);
		}
		/*ann.style.visibility = 'hidden'*/
		aState = 0;
		break;
	}

	if (aState == 0) {
		/*alert (height);*/
		/*ann.style.visibility = 'visible'*/
		for (var i=0; i < height; i++) {
			var t =setTimeout("a_extend("+i+")", 400+i);
		}
		aState = 1;
		break;
	}
	
	}
}
function a_extend(i) { 
	ann.style.height = i+'px';
}


