function launchApplianceCare()
{
	window.open('http://www.bshappliancecare.com/Neff/index.html'); 	
	history.go(-1);
	return true;
}
function submitAquestion()
{
	//document.getElementById("phThankyou").style.display='block';
	document.getElementById("phChoose").style.display='none';
	document.getElementById("phQuestion").style.display='block';
}
function questionSubmitted()
{
	document.getElementById("phThankyou").style.display='block';
	document.getElementById("phChoose").style.display='none';
	document.getElementById("phQuestion").style.display='none';
}

function loadUpJs()
{
	//resizeHeightCentralColumn() // Not required + causes problems with new styling
}

function toggleIconDiv(visible)
{
	if(visible)
	{
		document.getElementById("iconFeatureDiv").style.display='block';
		document.getElementById("iconHeaderDiv").style.display='none';
	}
	else
	{
		document.getElementById("iconFeatureDiv").style.display='none';
		document.getElementById("iconHeaderDiv").style.display='block';
	}
	
	return false;
}

function toggleNewsArchive(visible)
{
	if(visible)
	{
		document.getElementById("Archive").style.display='block';
		document.getElementById("ArchLink").style.display='none';
	}
	else
	{
		document.getElementById("Archive").style.display='none';
		document.getElementById("ArchLink").style.display='block';
	}
	
	return false;
}

function ShowHideFeatures(docId)
{
	var testObj;
	testObj = document.getElementById("iconFeatureDiv");
	if(testObj==null)
		return;
	
	toggleIconDiv(true);
	showHide('icon'+docId, true);
}

function resizeHeightCentralColumn()
{
	var centralColumn = document.getElementById("CentralColumnV2");
	var innerHeight;
	if (centralColumn)
	{
		if (window.innerHeight)
		{
			if (document.height < window.innerHeight)
			{
				innerHeight = window.innerHeight;
			}
		}
		else if (document.body.clientHeight)
		{
			innerHeight = document.body.clientHeight;
		}
		if (innerHeight)
		{
			centralColumn.style.height = innerHeight + 'px';
		}
	}
}

function checkForResize()

{
	// remove border graphics for small resolutions to remove horizontal scrollbars
	if(screen.width < 850)
	{
		document.body.className = "BodyV2Narrow";
		document.getElementById("RightColumnV2").className = "RightColumnV2Narrow";
		document.getElementById("LeftColumnV2").className = "LeftColumnV2Narrow";
	}
}

function MouseOverImage(strImgName, strFileName, strType) 
{
	var objImg;
	objImg = document.images[strImgName];
	if (! objImg) {
		return; // Abandon all hope!
	}

	if (strType == "PROD")
	{
		objImg.src = "images/products/buttons/" + strFileName;
	}
	else if (strType == "ICON")
	{
		objImg.src = strFileName;
	}
	else
	{
		objImg.src = "images/nav/top/" + strFileName;
	}
}

/* Added to support single XSL with different page nesting levels */
function MouseOverImageWithPath(rootPath, strImgName, strFileName, strType)
{
	var objImg;
	objImg = document.images[strImgName];
	if (! objImg) {
		return; // Abandon all hope!
	}

	if (strType == "PROD")
	{
		objImg.src = rootPath + "images/products/buttons/" + strFileName;
	}
	else if (strType == "ICON")
	{
		objImg.src = strFileName;
	}
	else
	{
		objImg.src = rootPath + "images/nav/top/" + strFileName;
	}
}	

function MouseOverCooksImage(strImgName, strFileName, strType) 
{
	var objImg;
	objImg = document.images[strImgName];
	if (! objImg) {
		return; // Abandon all hope!
	}

	if (strType == "PROD")
	{
		objImg.src = "../images/products/buttons/" + strFileName;
	}
	else if (strType == "ICON")
	{
		objImg.src = strFileName;
	}
	else
	{
		objImg.src = "../images/nav/top/" + strFileName;
	}
}		


function getLayer(layerName)
{
	var theLayer = document.getElementById(layerName);
	if (!theLayer)
		theLayer = document.getElementsByName(layerName)[0];
	return theLayer;		
}

var prevLayer = null;

function showHide(layerName, visible)
{
	
	var theLayer = getLayer(layerName);
	
	if(layerName.indexOf('icon')==0)
	{
		if(prevLayer != null)
		{
			if(prevLayer != theLayer)
			{
				prevLayer.style.visibility = 'hidden';
			}		
		}
		prevLayer = theLayer;
	}
		
	theLayer.style.visibility = (visible) ? 'hidden' : 'visible';
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/**** JS StringBuilder ****/

function StringBuilder(value)
{
	this.strings = new Array("");
	this.append(value);
}

// Appends the given value to the end of this instance.

StringBuilder.prototype.append = function (value)
{
	if (value)
	{
		this.strings.push(value);
	}
}

// Clears the string buffer

StringBuilder.prototype.clear = function ()
{
	this.strings.length = 1;
}

// Converts this instance to a String.

StringBuilder.prototype.toString = function ()
{
	return this.strings.join("");
}

function generateFooter()
{
	if (window.XMLHttpRequest)
	{
		xhttp=new XMLHttpRequest();
	}
	else // Internet Explorer 5/6
	{
		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xhttp.open("GET", "/Navigation/footer.xml", false);
	xhttp.send(null);
	var xmlDoc=xhttp.responseXML;

	var x=xmlDoc.getElementsByTagName("column");
	
	var sb = new StringBuilder();
	for (i=0;i<x.length;i++)
	{
		if(i == 0)
		{
			sb.append("<div class='FooterColumnL'>");
		}
		else
		{
			sb.append("<div class='FooterColumnM'>");
		}
			sb.append("<ul>");		
		var y=x[i].getElementsByTagName("link");
		for (j=0;j<y.length;j++)
		{
			var isTitle = y[j].getElementsByTagName("IsTitle")[0].childNodes[0].nodeValue;
			if(isTitle.toLowerCase() == "yes")
			{
				sb.append("<li class='FooterLiTitle'>");
				sb.append(y[j].getElementsByTagName("text")[0].childNodes[0].nodeValue);
				sb.append("</li>");
			}
			else if(isTitle.toLowerCase() == "ish")
			{
				sb.append("<li class='FooterLiLink_Ish'><a href='");
				sb.append(y[j].getElementsByTagName("url")[0].childNodes[0].nodeValue);
				sb.append("' target='");
				sb.append(y[j].getElementsByTagName("target")[0].childNodes[0].nodeValue);
				sb.append("'>");
				sb.append(y[j].getElementsByTagName("text")[0].childNodes[0].nodeValue);
				sb.append("</a></li>");
			}
			else
			{
				sb.append("<li class='FooterLiLink'><a href='");
				sb.append(y[j].getElementsByTagName("url")[0].childNodes[0].nodeValue);
				sb.append("' target='");
				sb.append(y[j].getElementsByTagName("target")[0].childNodes[0].nodeValue);
				sb.append("'>");
				sb.append(y[j].getElementsByTagName("text")[0].childNodes[0].nodeValue);
				sb.append("</a></li>");
			}
		}
		sb.append("</ul></div>");                        
	}
	document.getElementById("FooterColumns").innerHTML = sb.toString();
	
	
	// it calls the function that add the query string to the URL after a search
	changeFormSubmit();
}
function changeFormSubmit()
{
	document.getElementById('search_form').setAttribute("onsubmit", "editQString()");
}


function editQString()
{
	var obj = document.getElementById('search_form');
	var inputs = obj.getElementsByTagName("input");
	for(var i=0; i < obj.length;i++)
	{
		if(obj[i].getAttribute("class") == "searchBox")
		{
			queryString = obj[i].value;
		}
	}
	document.getElementById('search_form').setAttribute("action", document.getElementById('search_form').action + "?q=" + queryString);
}

