var rollObj        = new elcNavigation('rollObj');
rollObj.hasTimeout = false;
var pgnav          = new elcNavigation('pgnav');
pgnav.hasTimeout   = false;


function popWin(url,winName,popWidth,popHeight,popScroll,popResize) {
  if (!popScroll) { popScroll = 'no' }
  if (!popResize) { popResize = 0 }
  var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',location=no,toolbar=0,menubar=0,resizable='+popResize+',directories=0';
  var myWin = window.open(url, winName, options);
  myWin.focus();
}

function popWin2(url,winName, popWidth,popHeight,popScroll) { 
	    var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',location=no,toolbar=0,menubar=0,resizable=0,directories=0';
            var myWin = window.open(url, winName, options);
	    myWin.focus();
            var newHeight = parseInt(popHeight) + parseInt(20);
            //document.write(y);
            myWin.resizeTo(popWidth,newHeight);
}
function popup(url,scrollbars,width,height){
    var popupWindow;
    popupWindow = open(url, 'pxPopupWindow', 'toolbar=0,location=0,directories=0,status=0,menubars=0,resizable=0,scrollbars='+scrollbars+',width='+width+',height='+height+',top=20,left=20');
    if (popupWindow != null) {
        popupWindow.focus();
    }
}

var condText; 
function clearTextBoxOnCondition(textBox,conditionText){
        if(textBox.value == conditionText)
          textBox.value="";
	  condText=conditionText;
    }   

function fillTextBoxOnCondition(textBox){
        if(textBox.value == "") {
          textBox.value=condText;
        }
}

function checkMaxLength (textarea, evt, maxLength) {
	if (textarea.selected && evt.shiftKey)
	// ignore shift click for select
		return true;
	var allowKey = false;
	if (textarea.selected && textarea.selectedLength > 0)
		allowKey = true;
	else {
		var keyCode = document.layers ? evt.which : evt.keyCode;
		if (keyCode < 32 && keyCode != 13)
			allowKey = true;
		else
			allowKey = textarea.value.length < maxLength;
		}
	textarea.selected = false;
	return allowKey;
}

function storeSelection (field) {
	if (document.all) {
		field.selected = true;
		field.selectedLength = field.createTextRange ? document.selection.createRange().text.length : 1;
	}
}

/* Copied from elcNavigation and head_common.tmpl */
if ((typeof wsmlMakeWebServiceHref) == "undefined")
{
  wsmlMakeWebServiceHref =
  wsmlMakeResourceHref =
  wsmlMakeResourceUrl =
  wsmlMakeLeakHref =
  wsmlMakeComponentHref =
  wsmlMakeCssHref = new Function ("u", "return u;");
}

function elcSendURL( url ) {
	location.replace(wsmlMakeWebServiceHref(url));
}
function sendURL(targetURI) {
	window.location = wsmlMakeWebServiceHref(targetURI);
}

function setPNGtrans(img) {
	img.src='/images/shim.gif';
}

function getCookie(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 setCookie(name, value, expires, path, domain, secure) {
    document.cookie =
        name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function deleteCookie(name, path, domain) {
        document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
