
/*************************
	Tab highligher
**************************/
function Tab(str) {
	document.getElementById(str).style.backgroundColor = '#3366cc';
}
/******************************
	end Tab highligher
*******************************/

/********************************
	picture sizer
*******************************
var location_pics = 0;
var Height = 0;
function sizeLocation_Pics() {
location_pics = document.getElementById("location_pics");
Height = location_pics.scrollHeight;
location_pics.style.overflow = 'hidden';
return Height;


}


/*********************************
	end picture sizer 
*********************************/

/**********************************
	image slider
***********************************/
var speed = '5000';
var previmg = 0;
var outtime = 0;
var intime = 0;
var u;

function homeimgsliderprep() {
sfEls = document.getElementById('img').getElementsByTagName('img');
for (i=0; i<sfEls.length; i++) {
sfEls[i].style.zIndex = (sfEls.length-i);
if (i==0) {} else {

if (window.sidebar) { sfEls[i].style.opacity = 0; }
if (document.all) { sfEls[i].style["filter"]="alpha(opacity=0)"; }
}
}
setTimeout("homeimgslider()",5000);
}

function homeimgslider() {

var nextimg = previmg+1;
if (nextimg == 6) { nextimg=0; }


for (var i=0; i<=1; i+=(1/80)) {
setTimeout("fadein(" + (nextimg) + ", "+i+")", i*400);
setTimeout("fadeout(" + previmg +", "+(1-i)+")", i*400);
if (i==1) {
setTimeout("fadein(" + nextimg + ", 1)", i*600);
setTimeout("fadeout(" + previmg +", 0)", i*600);
}
}

previmg=nextimg;

setTimeout("homeimgslider()", 5000);
}

function fadein(u,i) {
var Img = document.getElementById('img').getElementsByTagName('img')[u];
if (window.sidebar) { Img.style.opacity = i; }
if (document.all) { Img.style["filter"]="alpha(opacity="+ (i*100) +")"; }
}



function fadeout(u,i) {
var Img2 = document.getElementById('img').getElementsByTagName('img')[u];

if (window.sidebar) { Img2.style.opacity=i; }
if (document.all) {Img2.style["filter"]="alpha(opacity="+ (i*100) +")";}
}


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

/////individual facility map /////
function initialize(loc_id,input,display) {

var address = '201 Gertrude Ave Atwater California 95301';

var map = new GMap2(document.getElementById("map_canvas"));
map.setMapType(G_NORMAL_MAP);

if (display == 1) { map.addControl(new GSmallMapControl()); }
else { map.disableDragging(); }
//map.addControl(new GMapTypeControl());

 // Create our "tiny" marker icon
var tinyIcon = new GIcon();
tinyIcon.image = "/templates/2-2/images/map_marker.gif";
//tinyIcon.shadow = "http://www.storageclicks.com/rev1/Champion Self Storage/images/map_marker_shadow.gif";
tinyIcon.iconSize = new GSize(17, 32);
tinyIcon.shadowSize = new GSize(19, 32);
tinyIcon.iconAnchor = new GPoint(8, 30);
tinyIcon.infoWindowAnchor = new GPoint(5, 1);

// Set up our GMarkerOptions object literal
markerOptions = { icon:tinyIcon };

if (input !== 0) {
document.getElementById("clear").style.display="inline";
document.getElementById("route").innerHTML = '';
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
directions.load(input +" to "+ address)

}

 geocoder = new GClientGeocoder();
if (input == 0) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point,markerOptions);
              map.addOverlay(marker);
              
            }
          }
        );
      }


} 

}

function clearDirections() {
	var route = document.getElementById("route");
	var clearTXT = "<table cellpadding=\"5\"><tr><td><b><span class=\"directions\">From the North:</span></b> 99 South to Atwater Blvd. Turn right to Shaffer. 2-3  miles on left.</td></tr>	<tr><td><b><span class=\"directions\">From the South:</span></b> Take Atwater Blvd. Shaffer Road Exit. Continue on Shaffer for 2-3 Miles. Facility on left on corner of Gertrude.</td></tr>	<tr><td><b><span class=\"directions\">From the East:</span></b> Take Shaffer Road west just past Santufe on left.</td></tr>	<tr><td><b><span class=\"directions\">From the West:</span></b> From 140 take Applegate Road to Atwater Blvd. Turn right to Shaffer road. Turn left, 2-3 miles on left.</td></tr></table>";

	route.innerHTML = clearTXT;
	document.getElementById("clear").style.display="none";
}


////// state map locations ////
	var gmarkers = [];

	// This function picks up the click and opens the corresponding info window
	function myclick(i) {
		
        	GEvent.trigger(gmarkers[i], "click");
		
      	}

 // A function to create the marker and set up the event window
      function createMarker(point,name,html) {

 // Create our "tiny" marker icon
var tinyIcon = new GIcon();
tinyIcon.image = "/templates/2-2/images/map_marker.gif";
//tinyIcon.shadow = "http://www.storageclicks.com/rev1/Champion Self Storage/images/map_marker_shadow.gif";
tinyIcon.iconSize = new GSize(17, 32);
tinyIcon.shadowSize = new GSize(19, 32);
tinyIcon.iconAnchor = new GPoint(8, 30);
tinyIcon.infoWindowAnchor = new GPoint(5, 1);

// Set up our GMarkerOptions object literal
markerOptions = { icon:tinyIcon };

        var marker = new GMarker(point,markerOptions);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers.push(marker);
       

         return marker;
      }


function func_state_map() {

      // this variable will collect the html which will eventually be placed in the side_bar
      var side_bar_html = "";
    
      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there



var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(0,0),0);
var bounds = new GLatLngBounds();
map.addControl(new GSmallMapControl()); 
//map.addControl(new GMapTypeControl());



var html = '';

html = '<div style="width:300px"><table>';
html += '<tr><td colspan="2"><b>Atlas Storage - Atwater</b></td></tr>';
html += '<tr><td width="100" valign="top"><img src="/images/gallery/87/pic1.jpg" alt="Atlas Storage - Atwater CA 95301" width="100" alt="" border="1"/></td>';
html += '<td valign="top">201 Gertrude Ave<br/>Atwater CA. 95301<br/>(209) 357-9757<br/><a href="Atwater-California-95301-87.html">More Information</a></td>';html += '</tr></table><\/div>';

var point = new GLatLng(37.3745909, -120.5972300);
var marker = createMarker(point,'this place',html)
map.addOverlay(marker);
bounds.extend(point);

map.setZoom(map.getBoundsZoomLevel(bounds)-1);
map.setCenter(bounds.getCenter());

}


////// ALL LOCATIONS ////


function func_all_locations_map() {

      
var map = new GMap2(document.getElementById("map_canvas"));
map.setMapType(G_NORMAL_MAP);
map.setCenter(new GLatLng(0,0),0);
var bounds = new GLatLngBounds();


map.disableDragging();


 // Create our "tiny" marker icon
var tinyIcon = new GIcon();
tinyIcon.image = "/templates/2-2/images/map_marker.gif";
//tinyIcon.shadow = "http://www.storageclicks.com/rev1/Champion Self Storage/images/map_marker_shadow.gif";
tinyIcon.iconSize = new GSize(17, 32);
tinyIcon.shadowSize = new GSize(19, 32);
tinyIcon.iconAnchor = new GPoint(8, 30);
tinyIcon.infoWindowAnchor = new GPoint(5, 1);

// Set up our GMarkerOptions object literal
markerOptions = { icon:tinyIcon };


var point = new GLatLng(37.3745909, -120.5972300);


var marker = new GMarker(point,markerOptions);

map.addOverlay(marker);
bounds.extend(point);

map.setZoom(map.getBoundsZoomLevel(bounds)-1);
map.setCenter(bounds.getCenter());

}	






// 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+".html","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)
{

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/2-2/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;
	}
}

//////// picture ///////////////////////////////////////////////////////////////


var prevPic = 1;

function showGalleryPic(id) {
	document.getElementById("pic"+prevPic).style.zIndex= 1;
	document.getElementById("pic"+id).style.zIndex= 3;
	prevPic = id;
}



