
function trim(stringVal) {
	return stringVal.replace(/^\s+|\s+$/g, "");
}

function delete_cookie(name, path, domain, secure) {
	var cookie_date = new Date(); // current date & time
	cookie_date.setTime(cookie_date.getTime() - 1);

	var cookie_string = name + "=; expires=" + cookie_date.toGMTString();

	if (path)
		cookie_string += "; path=" + escape(path);

	if (domain)
		cookie_string += "; domain=" + escape(domain);

	document.cookie = cookie_string;
}

function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {

	var cookie_string = name + "=" + escape(value);

	if (exp_y) {
		var expires = new Date(exp_y, exp_m, exp_d);
		cookie_string += "; expires=" + expires.toGMTString();
	}

	if (path)
		cookie_string += "; path=" + escape(path);

	if (domain)
		cookie_string += "; domain=" + escape(domain);

	if (secure)
		cookie_string += "; secure";

	document.cookie = cookie_string;
}

function get_cookie(cookie_name) {
	var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');

	if (results)
		return (unescape(results[1]));
	else
		return null;
}


function fixImgTitles() {
	var imgs = document.getElementsByTagName("img");
	for ( var i = 0; i < imgs.length; i++) {
		imgElm = imgs[i];

		titleAvailable = imgElm.title != null && trim(imgElm.title).length > 0;
		altAvailable = imgElm.alt != null && trim(imgElm.alt).length > 0;

		if (titleAvailable && !altAvailable) {
			imgElm.alt = trim(imgElm.title);
		} else if (!titleAvailable && altAvailable) {
			imgElm.title = trim(imgElm.alt);
		} else {
			// Do nothing
		}

	}
}

function fixPortalURL(){
			document.location.href="http://"+location.host+"/wps"+(location.href.indexOf("myportal")>-1?"/myportal":"/portal")+"/Uyelik";
    }
function fixWCMURL(pageName){
	document.location.href="http://"+location.host+"/wps"+(location.href.indexOf("myportal")>-1?"/myportal":"/portal")+"/"+pageName;
}