//gets the psid value from the cookie
function getpsidcookie() {
	var nameEQ = "PSID" + "=";
	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 true;
	}
	return false;
}

// returns prod env true/false...add prod apps as needed
function isProduction() {
	var theLocation = document.location.href;
	if (theLocation.indexOf("www.sybase.com") > -1 ||
	    theLocation.indexOf("search.sybase.com") > -1 ||
	    theLocation.indexOf("investor.sybase.com") > -1 ||
	    theLocation.indexOf("http://sybase.com") > -1 ||
	    theLocation.indexOf("downloads.sybase.com") > -1 ||
	    theLocation.indexOf("profile.sybase.com") > -1 ||
	    theLocation.indexOf("login.sybase.com") > -1 ||
	    theLocation.indexOf("my.sybase.com") > -1 ||
	    theLocation.indexOf("eshop.sybase.com") > -1 ||
	    theLocation.indexOf("certification.sybase.com") > -1 ||
	    theLocation.indexOf("info.sybase.com") > -1 ||
	    theLocation.indexOf("forums.sybase.com") > -1 ||
	    theLocation.indexOf("case-express.sybase.com") > -1 ||
	    theLocation.indexOf("casexpress.sybase.com") > -1 ||
	    theLocation.indexOf("sybooks.sybase.com") > -1 ||
	    theLocation.indexOf("infocenter.sybase.com") > -1 ||
	    theLocation.indexOf("ptnrweb.sybase.com") > -1 ||
	    theLocation.indexOf("crm.sybase.com") > -1 ||
	    theLocation.indexOf("jobs.sybase.com") > -1 ||
	    theLocation.indexOf("surveys.sybase.com") > -1 ||
	    theLocation.indexOf("sed.sybase.com") > -1 ||
	    theLocation.indexOf("www.sybase-iad-services.com") > -1 ||
	    theLocation.indexOf("techwave.sybase.com") > -1 ||
	    theLocation.indexOf("try.sybase.com") > -1 ||
	    theLocation.indexOf("blogs.sybase.com") > -1 ||
	    theLocation.indexOf("blog.sybase.com") > -1 ||
	    theLocation.indexOf("slc.sybase.com") > -1 ||
	    theLocation.indexOf("video.sybase.com") > -1 ){
		
		return true;
	} else {
		return false;
	}
}

// returns domain env true/false...add prod apps as needed
function whichApp() {
	var theLocation = document.location.href;
	var theQueryString = document.location.search;
	var app = "";
	
	if (theLocation.indexOf("/eshop") > -1 ){		
		return "eshop";
	} 
	
	if (theLocation.indexOf("/search/simple.do") > -1 ||
	    theLocation.indexOf("/search/advanced.do") > -1 ){		
		return  "search";
	}
	
	return "none"
 
}

//gets the correct websidestory account number for env
function getWSSAccount() {
	if (isProduction()){
	    account_no = "DM55021041AA94EN3"  
   	} else {
	    account_no = "DM550401PMDV94EN3"   	
   	} 
	return account_no;
}

//removes illegal characters from the title
//and plus pluses for spaces
function removeIllegalCharacters(title) {
    return title.replace(/[',"&|#$%^*:!<>~;]/g,"").replace(/\//g,"").replace(/\s/g,"+")
}

function getTitle() {
	varTitle = "";
	
	try {
		varShortTitle = document.getElementById("shortTitle");
		varTitle = varShortTitle.value;
	} catch (e) {
		varTitle = document.title;
	}
	
	return varTitle;

}

function getMlc() {
	varMlc = document.location.pathname;

	if (varMlc.indexOf("/detail") > -1 ){
		try {
			varInfo = document.getElementById("info");
			varMlc = varMlc + "/" + varInfo.value;;
		} catch (e) {}
	}
	return varMlc.replace(/\s/g,"+");

}
