/* brand-specific common library */
function elcSendURL( url ) {
    location.replace(wsmlMakeWebServiceHref(url));
}
function sendURL(targetURI) {
    window.location = wsmlMakeWebServiceHref(targetURI);
}
function elcGotoURL( url ) {
    if (url != null && url != '') {
        self.location.href = wsmlMakeWebServiceHref(url);
    }
}

/* popup window */
function popWin(url, winName, popWidth, popHeight, popTop, popLeft, popScroll){
    var top = (popTop == "undefined" || popTop < 0) ? 20 : popTop;
    var left = (popLeft == "undefined" || popLeft < 0) ? 20 : popLeft;
    var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',top='+top+',left='+left+',location=no,toolbar=0,menubar=0,resizable=0,directories=0';
    var myWin = window.open(url, winName, options);
    myWin.focus();
}
      
function properWindowOpener(url, w, h){
    var windowWidth  = w;
    var windowHeight = h;

    //find out how big the screen is
    var screenWidth  = screen.availWidth;
    var screenHeight = screen.availHeight;

    //get the left position - which is half the screen width minus half the window width
    var leftPoint = parseInt(screenWidth/2) - parseInt(windowWidth/2);
    //get the top position - which is half the screen height minus half the window height
    var topPoint  = parseInt(screenHeight/2) - parseInt(windowHeight/2);
  
    var winprops = 'height='+h+', left='+leftPoint+', top='+topPoint+', width='+w+', resizable=1'
    var win = window.open( url, "win", winprops);

    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* cookies */
function doNothing(){
	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	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 c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function isdefined(object, variable)
{
	return (typeof(eval(object)[variable]) != 'undefined');
}