
/* General Functions
------------------------------------------------ */
function loadPage()
{
	if( ! document.getElementById("navUrl").value )
	{
		if( checkIfPreview() )
		{
			loadMenu('/wpm/wpm.nsf/resources/navpreview.xml');
		}
		else{
			loadMenu('/wpm/wpm.nsf/resources/navpublish.xml');
		}
	}
	else
	{
		loadMenu( document.getElementById("navUrl").value );
	}
	//not sure if this is still required!
	if( document.forms[1] )
	{
		document.forms[1].thisPageUrl = location.href;
	}
}
function checkIfPreview(){
	var url=location.href;
      url= url.toLowerCase();
	if(url.match("preview")=="preview"){
		return true;
	}
	else {
		return false;
	}
}
function go(){
	window.location=document.getElementById("productmenu").value;
}
/* Print Page
This script will change the font size of any text within a paragraph (<p> tag). 
If you wish to change text within other tags edit the getElementsByTagName('p'); part. 
------------------------------------------------------*/
function printPage(){
	window.open (location.href  +'?var=Print','Print','width=615, height=800, scrollbars=1');
}
/* Increase / Decrease Font Size
This script will change the font size of any text within a paragraph (<p> tag). 
If you wish to change text within other tags edit the getElementsByTagName('p'); part. 
------------------------------------------------------*/
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}
/*function openConditions() {window.open( "/internet/allianz.nsf/docs/QB+Five+Percent+Conditions/$file/conditions-apply.html", "", "width=490,height=375,menu=no" ); }*/
function openConditions(){ window.open( "/lcp/lcplus.nsf/File?Open&v=docs&s=conditions-competition", "", "width=510,height=500,menu=no,scrollbars=yes" ); }
function openFindOutMore() {window.open( "http://allianz.acrobat.com/newallianzwebsite/", "", "width=800,height=600," ); }
function popapp(name, url) {
	var h = screen.height - (screen.height * 0.10);
	var x = (screen.width / 2) - 395;
	var y = 0;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var q = window.open(url, name, "width=790,height=" + h + ",top=" + y + ",left=" + x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_custwidth(name, url, width) {
	var h = screen.height - (screen.height * 0.10);
	var x = (screen.width - width) / 2;
	var y = (screen.height - h) / 2;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var q = window.open(url, name, "width=" + width + ",height=" + h + ",top=" + y + ",left=" + x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_maxheight(name, url, width, maxheight ) {
	var h = screen.height - (screen.height * 0.10);
                if( h > maxheight ) h = maxheight;
	var x = (screen.width - width) / 2;
	var y = (screen.height - h) / 2;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var q = window.open(url, name, "width=" + width + ",height=" + h + ",top=" + y + ",left=" + x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_life(name, url) {
	var life_h = screen.height - (screen.height * 0.10);
	var life_x = (screen.width / 2) - 395;
	var life_y = 0;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var life_q = window.open(url, name, "width=860,height=" + life_h + ",top=" + life_y + ",left=" + life_x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_home(name, url) {
	var home_h = screen.height - (screen.height * 0.10);
	var home_x = (screen.width / 2) - 395;
	var home_y = 0;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var life_q = window.open(url, name, "width=870,height=" + home_h + ",top=" + home_y + ",left=" + home_x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_payment(name, url) {
	var pay_h = screen.height - (screen.height * 0.10);
	var pay_x = (screen.width / 2) - 395;
	var pay_y = 0;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var pay_q = window.open(url, name, "width=860,height=" + pay_h + ",top=" + pay_y + ",left=" + pay_x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function popapp_payment2(name, url) {
	var pay_h = screen.height - (screen.height * 0.30);
	var pay_x = (screen.width / 2) - 395;
                
	var pay_y = 0;
	if(window.location.toString().indexOf("/wb/") > 0) {
		url = "/wb" + url;
	}
	var pay_q = window.open(url, name, "width=900,height=" + pay_h + ",top=" + pay_y + ",left=" + pay_x+ ",scrollbars=yes,menu=no,toolbar=no,status=yes");
	return false;
}
function getVariableContent( sItemKey )
{
   new Ajax.Request( '/lcp/lcplus.nsf/getVariableContent?openAgent&key=' + escape(sItemKey),
   {
      method: 'get',
      asynchronous: false,
      overrideMimeType: 'text/html',
      onSuccess: function( transport )
      {
         var response = transport.responseText || "Unable to retrieve variable content.";
         document.write( response );
      },
      onFailure: function()
      {
         document.write( "Unable to retrieve variable content." );
      }
   });
}

