var	WINDOW_OPEN_OPTIONS = "scrollbars=yes,resizable=yes,toolbar=no,left=10,top=0";

function PopWindowENVOYAgent() {
	special = WINDOW_OPEN_OPTIONS + "width=600,height=550";
	window.open ("http:/" + "/www.SoCalGas.com/business/envoy/form_Agent_Request.shtml", "ENVOYAgent", special +"");
}

function PopWindowENVOYRegistration() {
	special = WINDOW_OPEN_OPTIONS + "width=600,height=550";
	window.open ("http:/" + "/www.SoCalGas.com/business/envoy/form_ENVOY_Registration.shtml", "ENVOYRegistration", special +"");
}

function PopWindowNavigation() {
	special = WINDOW_OPEN_OPTIONS + "width=780,height=550";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_GlobalNav_ContextMenu.html", "navigation", special +"");
}

function PopWindowHelpUpload() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/help/help_wbt_4_1_1_pg9.html", "help", special +"");
}

function PopWindowPipelineMap() {
	special = WINDOW_OPEN_OPTIONS + "width=780,height=550,top=10";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_pipeline_map.html", "PipelineMap", special +"");
}

function PopWindowTrades() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_imbalance_trades.html", "help", special +"");
}

function PopWindowFAQ() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=650";
	window.open ("/faq.html", "help", special +"");
}

function PopWindowHelpTraining() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/help/help_wbt_home.html", "help", special +"");
}

function PopWindowContactUs() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/help/help_contactus.html", "help", special +"");
}

function PopWindowSystemRequirements() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/help/help_requirements.html", "help", special +"");
}

function PopWindowTransactionUpload() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/help/help_wbt_4_1_1_pg10.html", "upload", special +"");
}

function PopWindowTrades() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_imbalance_trades.html", "help", special +"");
}

function PopWindowCycles() {
	special = WINDOW_OPEN_OPTIONS + "width=780,height=550";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_cycles.html", "cyclesvideo", special +"");
}

function PopWindowElapsedProrata() {
	special = WINDOW_OPEN_OPTIONS + "width=770,height=550";
	window.open ("/browser_compliance.html?flash=6&url=/help/help_elapsed_prorata.html", "epvideo", special +"");
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var popupWindow = null;
function generateSessionUniqueWindowName()
{
	var windowName = "";
	var allCookies = document.cookie.split("; ");
	if (allCookies && allCookies.length > 0)
	{
		for (var i = 0; i < allCookies.length; i++)
		{
			var cookieName = allCookies[i].split("=")[0];
			var cookieValue = allCookies[i].split("=")[1];
			if (cookieName == "KryptonSession")
			{
				windowName = cookieValue.split("!")[0];
			}
		}
	}
	if (windowName == "")
	{
		var dateObj = new Date();
		windowName = "gs_" + dateObj.getTime();
	}
	return windowName;
}

function popNewWindow()
{
	if (!popupWindow || (popupWindow == null) || popupWindow.closed)
	{
		var windowName = generateSessionUniqueWindowName();

		var actualWidth = 900;
		var availWidth = screen.availWidth;
		if (availWidth < actualWidth)
		{
			actualWidth = 800;
		}

		popupWindow =
			window.open(
				"/login/",
				windowName,
				"alwaysRaised=true,directory=no,hotkeys=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,WIDTH="+actualWidth+",HEIGHT=500",
				true
			);
		popupWindow.offscreenBuffering = true;
	}

	popupWindow.focus();
}

// Envoy updates javascript


function changeButton(buttonName, imageSrc)
{
	document[buttonName].src = imageSrc;
}
