//This function open a new window and replaces old content with new content.//
function xWinOpen(sUrl)
{
  var xNewWindow = null;
  var xParameter = "left=200,top=0,width=800,height=600location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1";
  if (xNewWindow && !xNewWindow.closed) {xNewWindow.location.href = sUrl;}
  else {xNewWindow = window.open(sUrl, "xWinName", xParameter);}
  xNewWindow.focus();
  return false;
}

//This function open a new window with heigh and width specified by developer//
function openWIN(wURL,x,y)
{
  var nWindow = null;
  var wParameter = "left=200,top=0,width="+ x +",height="+ y +",location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1";
  if (nWindow && !nWindow.closed) {nWindow.location.href = wURL;}
  else {nWindow = window.open(wURL, "wWinName", wParameter);}
  nWindow.focus();
  return false;
}

//This function open a new window for sites listed in a dropdown menu and replaces old content with new content.//

function formHandler(form) {
        var w = 480, h = 340;
		var w = screen.width;
	   	var h = screen.height;
		var popW = 720, popH = 480;
		var leftPos = (w-popW)/2, topPos = (h-popH)/2;
		var windowprops = ('width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + 'resizable=yes,scrollbars=yes,menubar=yes')
        var URL = form.site.options[form.site.selectedIndex].value;
        if ( URL != "") {
			if (!window.window2) {
        	// has not yet been defined
        	window2 = window.open(URL,"MenuPopup",windowprops);
			}
    	else {
        	// has been defined
        	if (!window2.closed) {
            	// still open
            	window2 = window.open(URL,"MenuPopup",windowprops);
				window2.focus();
        	}
        	else {
            window2 = window2 = window.open(URL,"MenuPopup",windowprops);
			window2.focus();
			}
			}
		}
		}
        // End -->

//This function enables the open of new site using the dropdown menu.//
function jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//This function loads images
function loadedImages()
{   var img
   if (document.images){
      if (!loadedImages) loadedImages = new Array()
      for (var i=0; i < arguments.length; i++){
         img = new Image()
         img.src = arguments[i]
         loadedImages[loadedImages.length] = img
      }
   }
}
//Various open windows functions.//

    function openWindow(whereto, whoami) 
	{
		top.name = "mainwindow"
		self.name="spawningWindow";
		popup = window.open(whereto, whoami, "width=510,height=450,top=100,left=300,scrollbars=1,toolbar=0,status=0,resizeable=0,menubar=0,location=0,fullscreen=0,directories=0,channelmode=0");
    }
	
	function vbdiPopup(myURL) 
	{
        if (navigator.userAgent.indexOf("MSIE") && (navigator.appVersion.substring(0,1) == '2')) 
		{
        popup=window.open(myURL,'popup','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600')
        } 
		else 
		{
        popup=window.open(myURL,'popup','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600');
        popup.focus();
        }
    }

	function openPopup(myPick) 
	{
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-640)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-480)/2 : 0;
	settings = 'height='+480+',width='+640+',top='+TopPosition+',left='+LeftPosition+',toolbar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes';
   	popup=window.open(myPick,'otherSite',settings);
	popup.focus();
	}
	
	function pdfPopup(myPick) 
	{
    var win = null;
	LeftPosition = (screen.width) ? (screen.width-640)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-480)/2 : 0;
	settings = 'height='+480+',width='+640+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=yes';
   	popup=window.open(myPick,'pdfWindow',settings);
	popup.focus();
    }
		
	function openModule(whereto, whoami) 
	{
	top.name = "mainwindow"
	self.name="spawningWindow";
	popup = window.open(whereto, whoami, "width=830,height=600,top=50,left=100,scrollbars=1,toolbar=1,status=0,resizeable=1,menubar=0,location=1,fullscreen=0,directories=0,channelmode=0");
    }

	function openPopup2(myPick) {
	    	popup=window.open(myPick,'otherSite','toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=450');
	}
	
	
    function upopup3(myUrl) {
              popup=window.open(myUrl,'popup3','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=645,height=500');
        		popup.focus();
		}


//COOKIE CONTROL//
	
	function getCookieVal (offset) {
	  var endstr = document.cookie.indexOf (";", offset);
	  if (endstr == -1)
		endstr = document.cookie.length;
	  return unescape(document.cookie.substring(offset, endstr));
	}

	//
	//  Function to return the value of the cookie specified by "name".
	//    name - String object containing the cookie name.
	//    returns - String object containing the cookie value, or null if
	//      the cookie does not exist.
	//
	function GetCookie (name) {
	  var arg = name + "=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		  return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	  }
	  return null;
	}

	//
	//  Function to create or update a cookie.
	//    name - String object object containing the cookie name.
	//    value - String object containing the cookie value.  May contain
	//      any valid string characters.
	//    [expires] - Date object containing the expiration data of the cookie.  If
	//      omitted or null, expires the cookie at the end of the current session.
	//    [path] - String object indicating the path for which the cookie is valid.
	//      If omitted or null, uses the path of the calling document.
	//    [domain] - String object indicating the domain for which the cookie is
	//      valid.  If omitted or null, uses the domain of the calling document.
	//    [secure] - Boolean (true/false) value indicating whether cookie transmission
	//      requires a secure channel (HTTPS).  
	//
	//  The first two parameters are required.  The others, if supplied, must
	//  be passed in the order listed above.  To omit an unused optional field,
	//  use null as a place holder.  For example, to call SetCookie using name,
	//  value and path, you would code:
	//
	//      SetCookie ("myCookieName", "myCookieValue", null, "/");
	//
	//  Note that trailing omitted parameters do not require a placeholder.
	//
	//  To set a secure cookie for path "/myPath", that expires after the
	//  current session, you might code:
	//
	//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
	//
	function SetCookie (name, value) {
	  var argv = SetCookie.arguments;
	  var argc = SetCookie.arguments.length;
	  var expires = (argc > 2) ? argv[2] : null;
	  var path = (argc > 3) ? argv[3] : null;
	  var domain = (argc > 4) ? argv[4] : null;
	  var secure = (argc > 5) ? argv[5] : false;
	  document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
	}

	//  Function to delete a cookie. (Sets expiration date to current date/time)
	//    name - String object containing the cookie name
	//
	function DeleteCookie (name) {
	  var exp = new Date();
	  exp.setTime (exp.getTime() - 1);  // This cookie is history
	  var cval = GetCookie (name);
	  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}
/////END COOKIE CONTROL

function logout()
{
DeleteCookie('loginName');
location.href=("/advisor/controller/authentication/logout");
}


// End hiding the script -->
