// Misc. Java Document

<!--

function displayStatusMsg(msgStr)  {
	status=msgStr; document.MM_returnValue = true;
}

function preloadImages() { //v3.0

	var d=document; 
	
	if (d.images){ 
	
		if (!d.p) d.p=new Array();
		
		var i,j=d.p.length,a=preloadImages.arguments; 
		
		for(i=0; i<a.length; i++) {
			
			if (a[i].indexOf("#")!=0) { 
				d.p[j]=new Image; d.p[j++].src=a[i];
			}			
		}			
	}
}

function displayStatusMsg(msgStr)  {
	status=msgStr; document.returnValue = true;
}

function findObj(n, d) {

	var p,i,x;
	
	if (!d) d=document; 
	
	if ((p=n.indexOf("?"))>0&&parent.frames.length) {
	  
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	
	}
	
	if (!(x=d[n])&&d.all)
		x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
		
	for (i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=findObj(n,d.layers[i].document);
		
	if (!x && d.getElementById) 
		x=d.getElementById(n); 
	
	return x;
	
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function is_windowInside() {
	
	var position, URL, googleSite
	
	URL = location.href;
	position = URL.indexOf("?");
		
	if (position != 0)
		googleSite = true;
	else
		googleSite = false;
			
	if (URL != 'http://www.saltlakechamber.org/search/search.asp' && 
		googleSite && top.location.href != self.location.href) {
		
		return true;
		
	}		
	else {
		
		return false;
		
	}
		
}

function windowInside() {
			 
	if (is_windowInside()) {
		top.location.href = self.location.href;
		return true;
	}
	else
		return false;
		
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function checkEmail(emailStr) {
// the following expression must be all on one line...
	var verified = emailStr.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	
	if (verified)
	   return true;
	else
	   return false;
	   
}

function mailThisURL(tagID) {
	
	var URL, emailObject;
	
	emailObject = findObj(tagID, document);
	
	URL = top.location.href;

	URL = URLEncode(URL);
	mailSubject = "WebSite :: Link";
   
	if (checkEmail(emailObject.value))
		window.location = "mailto:" + emailObject.value + "?subject=" + mailSubject + "&body=" + window.document.title + " " + URL;
	else {
		
	   alert('Please enter a valid email address...');
	   
	   emailObject.focus();
	   emailObject.select();
	   return false;
	   
	}
}

function mailThisURL_directory(path) {
	
	var URL, position, query, emailObject;
	
	emailObject = findObj('emailURL', document);
	
	URL = self.location.href;
	
	position = URL.indexOf("?");
	
	if (position != 0) {
		query = URL.substring(position, URL.length);
		
		position = query.indexOf("childWindow=true");
		
		if (position != 0) {
			
			query = query.substring(position + 16, URL.length);
			
			if (query[0] == "&")
				query = query.substring(1, URL.length);
				
			query = "?" + query;
		
		}		
		
	}
	else {
		query = "";
	}
	
	URL = path + '/' + query;
	URL = URLEncode(URL);
	mailSubject = "WebSite :: Link";
   
	if (checkEmail(emailObject.value))
		window.location = "mailto:" + emailObject.value + "?subject=" + mailSubject + "&body=" + window.document.title + " " + URL;
	else {
		
	   alert('Please enter a valid email address...');
	   
	   emailObject.focus();
	   emailObject.select();
	   return false;
	   
	}
}

function execute_comboBox(tag_ID, sEval) {
	
	var oTag = findObj(tag_ID, document);
	
	eval(sEval + oTag.options[oTag.selectedIndex].value + ";");
	
	return true;
	
}

function displayHide_tag(tagID) {
   
	var tagObject = findObj(tagID, document);
	
	if (tagObject.style)		  
		tagObject.style.display = tagObject.style.display == 'block'?'none':'block';
	
	return true;

	  
}

//-------------------
// Opacity
//-------------------

//change the opacity for different browsers
function setOpacity(tagID, opacity) {	

	var objectStyle = findObj(tagID).style;
	
	opacity = (opacity == 100)?99.999:opacity;
	
	objectStyle.opacity = (opacity / 100);
	objectStyle.MozOpacity = (opacity / 100);
	objectStyle.KhtmlOpacity = (opacity / 100);
	objectStyle.filter = "alpha(opacity=" + opacity + ")";
	
}

function opacity(tagID, opacity_start, opacity_end, millisec) {
	
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacity_start > opacity_end) {
		
        for(opacityValue = opacity_start; opacityValue >= opacity_end; opacityValue--) {
			
            setTimeout("change_opacity('" + tagID + "'," + opacityValue + ")",(timer * speed));
            timer++;
			
        }
    } 
	else if(opacity_start < opacity_end) {
		
        for(opacityValue = opacity_start; opacityValue <= opacity_end; opacityValue++) {
			
            setTimeout("change_opacity('" + tagID + "'," + opacityValue + ")",(timer * speed));
            timer++;
			
        }
    }
} 

function current_opacity(tagID) {

	var objectTag = findObj(tagID);
		
	var current_opacity;
	
	if (objectTag.filters) {		
		current_opacity = objectTag.filters.item('alpha').opacity;		
	}
	else if (objectTag.style.MozOpacity) {
		current_opacity = objectTag.style.MozOpacity * 100;
	}
	else if (objectTag.style.khtml-opacity) {
		current_opacity = objectTag.style.khtml-opacity * 100;
	}
	else return 100;
	
	if(current_opacity == 'undefined') {
		
		current_opacity = objectTag.style.opacity;
		if(current_opacity == 'undefined') objectTag.style.MozOpacity;
		if(current_opacity == 'undefined') objectTag.style.KhtmlOpacity;
		
		if(current_opacity == 'undefined') current_opacity = 100;		
    
		//if the element has an opacity set, get it
		if(current_opacity < 100)		
			current_opacity *= 100;
			
	}

    return current_opacity;
	
}

//change the opacity for different browsers
function change_opacity(tagID, opacity) {

	var objectStyle = findObj(tagID).style; 
	
	opacity = (opacity == 100)?99.999:opacity;
	
	objectStyle.opacity = (opacity / 100);
	objectStyle.MozOpacity = (opacity / 100);
	objectStyle.KhtmlOpacity = (opacity / 100);
	objectStyle.filter = "alpha(opacity=" + opacity + ")";
	
}

function shiftOpacity(tagID, millisec) {
	
	//if an element is invisible, make it visible, else make it ivisible
	if(findObj(tagID).style.opacity == 0) {
		
		opacity(tagID, 0, 100, millisec);
		
	} 
	else {
		
		opacity(tagID, 100, 0, millisec);
		
	}	
}

function blendimage(div_tagID, image_tagID, image_src, millisec) {
	
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	findObj(div_tagID).style.backgroundImage = "url(" + document.getElementById(image_tagID).src + ")";
	
	//make image transparent
	change_opacity(image_tagID, 0);
	
	//make new image
	document.getElementById(imageid).src = image_src;

	//fade in image
	for(opacity = 0; opacity <= 100; opacity++) {
		
		setTimeout("change_opacity('" + image_tagID + "', " + opacity + ")",(timer * speed));
		timer++;
		
	}
}

function fade_opacity(tagID, opacity_end, millisec) {
	
	//call for the function that changes the opacity
	opacity(tagID, current_opacity(tagID), opacity_end, millisec);
	
}

-->