
function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function checkForEmpty(searchString) {
	if(trim(searchString) != "") {
		document.getElementById("globalSearchForm").submit();
	}
	else {
		window.location="/utilities/search.esp"
	}
}

var multipleLangCountries =[["http://dev-engb.emc.com", "/langInterceptor-Canada.htm","Canadalanguage1!http://dev1-engb.emc.com/index.htm#Canadalanguage2!http://dev-engb.emc.com/index.htm"], ["http://dev-de.emc.com", "/langInterceptor-Germany.htm","Germanylanguage1!http://dev1-de.emc.com/index.htm#Germanylanguage2!http://dev-de.emc.com/index.htm"]];


function ReadCookie(name) {
	var cookieString = document.cookie;
	var cookiesArray = document.cookie.split(";");
	if(cookiesArray.length >1) {
		for(var i=0;i<cookiesArray.length;i++) {
			cookieArray = cookiesArray[i].split("=");
			cookieName = cookieArray[0];
			cookieValue = cookieArray[1];
			if(cookieName.indexOf(name) >= 0) {
				return cookieValue;
			}
		}
	}
	else {
		cookieArray = cookieString.split("=");
		cookieName = cookieArray[0];
		cookieValue = cookieArray[1];
		if(cookieName.indexOf(name) >= 0) {
			return cookieValue;
		}
	}
	return "";
}


function redirectSite(siteUrl) {
	if(document.getElementById("rememberchoice")) {
		if(document.getElementById("rememberchoice").checked) {
			window.status = ip;
			if((ip.indexOf("128.221.24") < 0) && (ip.indexOf("10.24.3") < 0))
				document.cookie = "EMCSiteUrl="+unescape(siteUrl)+";expires=Fri, 17 Dec 2020 10:00:00 GMT;domain=emc.com;path=/";
		}
	}
	if(siteUrl != "") {
		redirectUrl(siteUrl);
	}
}

function redirectUrl(url) {
	for(var i=0;i<multipleLangCountries.length;i++) {
		
		if(url.indexOf(multipleLangCountries[i][0]) != -1)  {
			window.location = multipleLangCountries[i][0]+multipleLangCountries[i][1];
			return;
		}
	}
	window.location = url+"?fromGlobalSiteSelect";
}

function redirectToSite (url) {
	if(ReadCookie("EMCSiteUrl").indexOf(url) > 0) {
			document.cookie = "EMCSiteUrl="+unescape(url)+";expires=Fri, 17 Dec 2020 10:00:00 GMT;domain=emc.com;path=/";
		}
	window.location = url;
}

function selectLanguage(selectLanguage,siteUrl) {
	if((ip.indexOf("128.221.24") < 0) && (ip.indexOf("10.24.3") < 0))
		document.cookie = "EMCSiteUrl="+unescape(siteUrl)+";expires=Fri, 17 Dec 2020 10:00:00 GMT;domain=emc.com";
	window.location=siteUrl;
}

if(self.pageTitle) {
	var cookieValue =  ReadCookie("tabName");
	if(cookieValue != "") {
		  var cookieValues  =  cookieValue.split("<<>>");
		  var pageName = cookieValues[0];
		  var tabName = cookieValues[1];

			  if(pageName == pageTitle) {
				if(tabName != "") {
					if(self.displayTab) {
						displayTab(document.getElementById("tab"+tabName));
					}
					else {
						if(document.getElementById("tab"+tabName+"Link")) {
							document.getElementById("tab"+tabName+"Link").onclick();
						}
					}
				}
			}
	}
}
 
