// JavaScript Document
function yaImgChange(imgNum,imgSrc) {
	document.images[imgNum].src = imgSrc;
}

function drivingDirections(){
	newWindow=window.open('driving.php','','width=500,height='+(screen.height-120)+',location=no,status=no,toolbars=no,resize=yes,scrollbars=yes');
}

function tvSampler(){
	newWindow=window.open('sampler.html','','width=300,height=300,location=no,status=no,toolbars=no,resize=no,scrollbars=no');
}
function showEditForm(browser){
	if (browser=="ie"){
			if (loginLayer.style.display=='block'){
				loginLayer.style.display='none';
			} else {
				loginLayer.style.display='block';
				document.actualForm.username.focus();
			}
	} else {
			if (document.getElementById('loginLayer').style.display=='block'){
				document.getElementById('loginLayer').style.display='none';
			} else {
				document.getElementById('loginLayer').style.display='block';
				document.actualForm.username.focus();
			}
	}
}
var tout;
function showDiv(id){
	document.getElementById(id).style.display='block';
}
function hideDiv(id){
	setTimeout("hideDiv2('"+id+"')",2500);
}
function hideDiv2(id){
	document.getElementById(id).style.display='none';
}
function toggleDiv(id){
	if (document.getElementById(id).style.display=='block'){
		document.getElementById(id).style.display='none';
	} else {
		document.getElementById(id).style.display='block';
	}
}

var speed = 2;
function fadeOut(id){
	var timer=0;
	if(document.getElementById(id).style.display!="none"){
		for(i = 100; i >= 0; i--) {
			setTimeout("changeOpac(" + i + ", '"+id+"')",(timer * speed));
			timer++;
		}
	}
	setTimeout("showDiv('"+id+"')",500);
}
	
function fadeIn(id,finalOpac){
	var timer=0;
	document.getElementById(id).style.display="block";
	for(i = 0; i <= finalOpac; i++) {
		setTimeout("changeOpac(" + i + ", '"+id+"')",(timer * speed));
		timer++;
	}
	
}
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}






// -----------------------------------------------
// Begin cookie functions
// -----------------------------------------------
 
// getCookieData() function is called from other cookie functions
// Takes cookie label as argument, returns cookie value or null
// -----------------
function getCookieData(label) {
    var labelLen = label.length
    var cLen = document.cookie.length
    var i = 0
    var cEnd
    while (i < cLen) {
        var j = i + labelLen
        if (document.cookie.substring(i,j) == label) {
            cEnd = document.cookie.indexOf(";",j)
            if (cEnd == -1) {
                cEnd = document.cookie.length
            }
            return unescape(document.cookie.substring(j,cEnd))
        }
        i++
    }
    return null
}
 
// loadCookieData() function is called from page with the contact form
// Populates hidden form fields in the first form of the page
// -----------------
function loadCookieValues()
{
 if (getCookieData("cookieRefURL"))
 {
  var field1 = document.forms[0].cRefURL
  field1.value = getCookieData("cookieRefURL")
  var field2 = document.forms[0].cLandURL
  field2.value = getCookieData("cookieLandURL")
  var field3 = document.forms[0].cDate
  field3.value = getCookieData("cookieDate")
 }
}
 
// cookieTreat() function is called from every page on the site
// Checks if cookies exist, if not - three cookie values are written
// -----------------
function cookieTreat() 
{
 var exp = new Date()
 var oneYearFromNow = exp.getTime() + (365 * 24* 60 * 60 * 1000)
 exp.setTime(oneYearFromNow)
 
 var today = new Date()
 
 var checkref = new String(" ")
 if(document.referrer.length > 0)
  {
  checkref = checkref + document.referrer
  }
 else
  {
  checkref = checkref + "No Referrer"
  }
 
 // set document cookie if they have not been written yet
 // if referrer cookie exists, do nothing
 // otherwise write all three cookies
 
 if (getCookieData("cookieRefURL") && getCookieData("cookieLandURL") && getCookieData("cookieDate")) { 
 
 }
 else {
  document.cookie = "cookieRefURL=" + checkref + "; domain=.schwartz-pr.com; expires=" + exp.toGMTString() + "; path=/"
  document.cookie = "cookieLandURL=" + location + "; domain=.schwartz-pr.com; expires=" + exp.toGMTString() + "; path=/"
  document.cookie = "cookieDate=" + today + "; domain=.schwartz-pr.com; expires=" + exp.toGMTString() + "; path=/"
 }
 
}

cookieTreat();
// -----------------------------------------------
// End cookie functions
// -----------------------------------------------
 


// -----------------------------------------------
// End cookie functions
// -----------------------------------------------
