

// changeImage function
function ChangeImage(ImageName, NewImage, Title, Directory)
{
if (document.images)
	{
	if (String (Directory) != "undefined")
		document[ImageName].src = Directory + "/" + NewImage;
	else
		document[ImageName].src = "images/" + NewImage;
	}

if (String (Title) != "undefined")
	window.status=Title;
else
	window.status=' ';
}

function ChangeImageBK(ImageName, NewImage, Directory)
{
		
		if (String (Directory) != "undefined")
			bkImage = "url(" + Directory + "/" + NewImage + ")";
		else
			bkImage = "url(/images/" + NewImage + ")";		

				
		if(document.layers) // browser="NN4"; 
			document.layers[ImageName].backgroundImage = bkImage;
		
		if(document.all) // browser="IE"; 
			document.all[ImageName].style.backgroundImage = bkImage;
		 	
		if(!document.all && document.getElementById) // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
			document.getElementById(ImageName).style.backgroundImage = bkImage;
}

function chgbk(id, newcolor)
{
	if(document.layers) // browser="NN4"; 
		document.layers[id].bgColor = newcolor; 
	
	if(document.all) // browser="IE"; 
		document.all[id].style.backgroundColor = newcolor; 
	
	if(!document.all && document.getElementById) // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
		document.getElementById(id).style.backgroundColor = newcolor; 
}

function chgBkgd(id, className)
{
	if(document.layers) // browser="NN4"; 
		document.layers[id].className = className; 
		
	if(document.all) // browser="IE"; 
		document.all[id].className = className; 
		
	if(!document.all && document.getElementById) // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
		document.getElementById(id).className = className; 
}

function chgLink(id, color)
{
	if(color=='y')
		newcolor = "#FBB71A";
	else if(color=='w')
		newcolor = "#FFFFFF";
	else if(color=='b')
		newcolor = "#0077CC";		
		
	if(document.layers) // browser="NN4"; 
		document.layers[id].color = newcolor; 
		
	if(document.all) // browser="IE"; 
		document.all[id].style.color = newcolor; 
		
	if(!document.all && document.getElementById) // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
		document.getElementById(id).style.color = newcolor; 
}

function chgDiv(id, text)
{
	if(document.layers) // browser="NN4"; 
		document.layers[id].innerHTML = text; 
		
	if(document.all) // browser="IE"; 
		document.all[id].innerHTML = text; 
		
	if(!document.all && document.getElementById) // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
		document.getElementById(id).innerHTML = text; 
}

/*sskelton 7/24/06 created my own custom status featured 2 and 3 for redesign of homepage*/
function featureRoll(id, status, text, vision)
{
	if (status == '3'){
		chgDiv('textFeatured', text);
		ChangeImage('bk1_' + id, 'tab_grow_' + vision + '.gif', text, '../../images/home');
	}
	else if (status == '2'){
		chgDiv('textFeatured', text);
		ChangeImage('bk1_' + id, 'tab_grow_' + vision + '_roll.gif', text, '../../images/home');
	}
	else if (status == '1'){
		if(id == 'feature3')
			ChangeImage('flbumper', 'bumper_right_icon_roll.gif', text, '/images/home');
			
		ChangeImage(id, 'icon_' + vision + '_roll.gif', text, '/images/home');
		chgBkgd('bk1_' + id, 'w');
		chgBkgd('bk2_' + id, 'w');						
		chgDiv('textFeatured', text);
		chgLink(id + 'L1', 'y');
		chgLink(id + 'L2', 'y');		
		ChangeImageBK('textBK', 'sub_textarea_1.jpg', '/images/home');
	}
	else{
		if(id == 'feature3')
			ChangeImage('flbumper', 'bumper_right_icon.gif', text, '/images/home');	
		
			
		ChangeImage(id, 'icon_' + vision + '.gif', text, '/images/home');
		chgBkgd('bk1_' + id, 'r');		
		chgBkgd('bk2_' + id, 'r');		
		chgLink(id + 'L1', 'w');
		chgLink(id + 'L2', 'w');		
		ChangeImageBK('textBK', 'sub_textarea_0.jpg', '/images/home');
		chgDiv('textFeatured', '');
	}
}

function subfeatureRoll(id, status)
{	
	if (status == '0'){
		chgBkgd(id, 'w');
		chgLink(id + 'L', 'b');		
	}
	else{
		chgBkgd(id, 'r');
		chgLink(id + 'L', 'w');			
	}
}

// index dropdown url redirect
function openGlobalSiteWindow (langLink) {
	// document.write(langLink);
/*
	var accessForm = document.form_select;
	var optionIndex = accessForm.languages.selectedIndex;
	var langLink = accessForm.languages.options[optionIndex].value; */
	if (langLink != null && langLink.length > 0) {
		document.location = langLink;
	}

}

function openPrintWindow (url) {
        window.open(url,"print","height=396,width=650,status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,location=no");
	return; 
}

function movieAction(movieName, movieAction) {

	dcsMultiTrack('DCS.dcsuri', 'flashtracking.ft', 'DCSext.Movie', movieName,  'DCSext.MovieAction', movieAction);
 
}

function popupWindow(filename,windowname,width,height)  
{
popup=window.open(filename,windowname,"width="+width+",height="+height+",resizable=yes,status=no,toolbar=yes,directories=no,menubar=yes,scrollbars=yes,location=no");
}


// mutateURL function - compares a give URL to the itron url, and if not internal, 
//   slaps it on the back of the redir page
function mutateURL(hrefObj)
{
/*
	var escURL, escRef;
	var url = new String;
	var newURL = new String;
	newURL = "";
	var redirURL = "/pages/redir.asp?url="
	newURL = newURL.concat(redirURL);
	// check to see if url is an external or internal url
	var compString1 = "http";
	var compString2 = "www.itron.com";
	var compString3 = "itron-qa.enlighten.com";
	var compString4 = "itron-dev.enlighten.com";
	url = hrefObj.href;
	
	if ( url.indexOf(compString1) != -1 && url.indexOf(compString1) < 3) {
		if ( url.indexOf(compString2) != -1 && url.indexOf(compString3) != -1 && url.indexOf(compString4) != -1 )
			//internal?  Get out!
				return true;
			//external?  urlencode it
		else		
		{
				escURL = encodeURIComponent(url);
				newURL = newURL.concat(escURL);
		}
	
		//get the refererer
		if (document.location) 
		{
			escRef = encodeURI(document.location);
			newURL = newURL.concat("&ref=",escRef);
		}
		hrefObj.href = newURL;
	}
	*/
	return true;
}


function qs()
{
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++)
    {
        var pos = parms[i].indexOf('=');
        if (pos > 0)
        {
            var key = parms[i].substring(0,pos);
            var val = parms[i].substring(pos+1);
            qsParm[key] = val;
        }
    }
}

var keyCount = 0;
function generateKey(targetForm)
{
    var xmlHttp;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
          try
          {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e)
          {
              alert("Your browser does not support AJAX!");
              return false;
          }
        }
    }
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if(keyCount == 0)
            {
                cookieForms('open', targetForm);
            }
            else
            {
                formSubmit(targetForm);        
            }
            keyCount++;
        }
    };
    xmlHttp.open("GET", "/pages/generateKey.asp?num=" + keyCount , false);
    xmlHttp.send(null);
}
