﻿// JScript File


function swapImage(imgName, newSrc) {
	document.images(imgName).src = newSrc;
}


function google_maps() {

	var urlstr = 'http://maps.google.com?f=d&hl=en&saddr=' + document.forms[0].textbox_address.value + '+' + document.forms[0].textbox_city.value + '+' + document.forms[0].dropdown_state.value + '+' + document.forms[0].textbox_zip.value + '&daddr=' + document.forms[0].daddr.value
	window.open(urlstr)
	
}

//sets up a url to get directions at Google Maps

function appendString(){
	var urlstr = 'http://maps.google.com?f=d&hl=en&saddr=' + form_google.textbox_address.value + '+' + form_google.textbox_city.value + '+' + form_google.list_state.value + '+' + form_google.textbox_zip.value + '&daddr=' + form_google.daddr.value
	window.open(urlstr)
}


function checkVal(imgName, newSrc) {
	document.images(imgName).src = newSrc;
}


function swapImage(imgName, newSrc) {
	document.images(imgName).src = newSrc;
}

function change_background(color) {
	document.getElementById('ctl00_panel_nav').style.backgroundColor = color;
}

function setVisible(obj) {

    windowHeight = document.body.offsetHeight
    windowWidth = document.body.offsetWidth
    
    brwserleft = (windowWidth/2) - 200
    brwsertop =  (windowHeight/4) + 200
    
	obj = document.getElementById(obj);
	
	if(obj.style.visibility == 'visible'){
	    obj.innerHTML = ''
	}
	
	obj.style.left = brwserleft;
	obj.style.top = brwsertop;
	obj.style.display = 'block';
	obj.style.visibility = 'visible';
	
}

function setImageVisible(obj, image_path) {

    if(document.getElementById('div_image_popup').style.visibility == 'visible'){
	    document.getElementById('div_image_popup').style.visibility = 'hidden';
	}

    document.getElementById('image_popup').src = image_path;

    windowHeight = document.body.offsetHeight
    windowWidth = document.body.offsetWidth
    
    brwserleft = (windowWidth/2) - 200
    brwsertop =  (windowHeight/4) + 100
    
	obj = document.getElementById(obj);
	
	if(obj.style.visibility == 'visible'){
	    obj.innerHTML = ''
	}
	
	obj.style.left = brwserleft;
	obj.style.top = brwsertop;
	obj.style.visibility = 'visible';
	
}

function setPopupMain(obj, image_path) {

    if(document.getElementById('div_image_popup').style.visibility == 'visible'){
	    document.getElementById('div_image_popup').style.visibility = 'hidden';
	}

    document.getElementById('image_popup').src = image_path;

    windowHeight = document.body.offsetHeight
    windowWidth = document.body.offsetWidth
    
    brwserleft = (windowWidth/2) - 400
    brwsertop =  (windowHeight/4) + -50
    
	obj = document.getElementById(obj);
	
	if(obj.style.visibility == 'visible'){
	    obj.innerHTML = ''
	}
	
	obj.style.left = brwserleft;
	obj.style.top = brwsertop;
	obj.style.visibility = 'visible';
	
}

function setInVisible(obj) {
	obj = document.getElementById(obj);
	obj.style.visibility = 'hidden';
}

function ajaxRequest(url){
    
    var httpRequest; 
    
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }

    http_request.open("POST", url, true); 
    http_request.onreadystatechange = function(){
        processRequest()
    }
    
    http_request.send(null);
}

function processRequest() 
{             
    if (http_request.readyState == 4)
    { 
        if(http_request.status == 200) 
        { 
           document.getElementById('div_disclaimers').innerHTML = http_request.responseText
        } 
        else 
        { 
            alert("Error loading page\n"+ http_request.status +":"+ http_request.statusText); 
        } 
    }         
}

