

//************popups*******************
var pop = null //window handle
function openPop(URL,w,h){
	if (pop && !pop.closed){//close existing window first
    closePop()
  }
  //if width and height are not explicit, use default values
  var width
  var height
  if(w) width = w
  else width = "500"
  if(h) height = h
  else height = "600"
  
  //open new popup, store in handle variable and set focus
  pop = window.open(URL,"pop","scrollbars=yes,resizable=yes,width="+width+",height="+height+",left=20,top=20")
  pop.focus()
  return false
}

function closePop() {
	//close existing window
  if(pop && !pop.closed) {
    pop.close()
    pop = null //clean up window handle
  }
}

function openLocation(location){
	window.opener.location = location
  window.close()
  return false
}

//**************** displays location popup on index.php  ***************
// JavaScript Document
$(document).ready(function(){
	var urlvar=window.location.href.slice(window.location.href.indexOf('?')+1);
	if(urlvar=='locations-pop'){
		$('#storeLocationsPopup').css('display','block');
	}
});

//*********contact us validation*********************
var emailChecked = false; //global flag to allow submitting without an e-mail address

function checkForm() {         
  if (document.email_us.Visitors_Message.value == ""){ 
    alert ("Please enter a message.") 
    document.email_us.Visitors_Message.focus(); 
    return false;
  }
  
  var validEmailTest = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
  if(!validEmailTest.test(document.email_us.from.value) && !emailChecked){
    alert ("If you'd like a response to your message, please enter a valid e-mail address.") 
    document.email_us.from.focus(); 
    emailChecked = true;
    return false;
  }
  
  document.email_us.subject.value = document.email_us.to[document.email_us.to.selectedIndex].text;
  document.email_us.Visitors_Browser.value = navigator.appName + " " + navigator.appVersion;
  document.email_us.Visitors_Platform.value = navigator.platform;
  document.email_us.Visitors_Version.value = navigator.appVersion; 
  
  var message = ""; 
  message += "<br><b>Message: </b>" + document.email_us.Visitors_Message.value; 
  message += "<br><br> Visitors system information:";
  message += "<br><b>Browser: </b>" + document.email_us.Visitors_Browser.value; 
  message += "<br><b>Browser version: </b>" + document.email_us.Visitors_Version.value;
  message += "<br><b>Platform: </b>" + document.email_us.Visitors_Platform.value; 
  document.email_us.MSGCONTENT.value = message; 
  return true;
}


//********* show/hide popover *********************

function hide(id){
	document.getElementById(id).style.display = 'none';
}

function show(id){
	document.getElementById(id).style.display = 'block';
}


/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid, location){
var page_request = false
var location = document.getElementById('location').value;
var url = url+location
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
