var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n'+'\n\<TABLE width=100% height=70 border=0 cellPadding=0 cellSpacing=0><TR vAlign=middle align=left>\n'+'\n<TD width=50%><img src=../../image/wealth_mgmt/logo_ocbc.gif width=210 height=46 hspace=7></a></TD>\n'+'\n<TD width=50% align=right><img src=../../image/wealth_mgmt/wm_logo.jpg width=147 height=59 hspace=14></TD>\n'+'\n</TR><TR><TD></TD><TD class=\"clsTaglineContent\" align=\"right\">Real Solutions. Always. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TABLE>\n';

		
		var printheadElem = document.getElementById("printhead");		
		
		if (printheadElem != null)
		{
				html += printheadElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		
		html += '\n<table width=96%  border=0 align=center cellpadding=0 cellspacing=0><tr><td align=left valign=top><br>\n';


		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</td></tr></table>\n'+'\n<br><br>\n'+'\n<table width=100%  border=0 cellpadding=0 cellspacing=0>\n'+'\n<tr>\n'+'\n<td height=25 align=center bgcolor=#FFF8DC class=clsFooter>&copy; Copyright 2004, 2005 - OCBC Bank. | All Rights Reserved | Co. Reg. No.: 193200032W</td>\n'+'\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printSpecial","menubar=yes,location=0,status=0,scrollbars=1");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}


// Dynamic Font Changes

var graphics_path = "" ;
var graphics_init = 0 ;

graphics_path = "../../image/wealth_mgmt";

function init_path()
{
	//graphics_path = document.getElementById("default").src ; // "graphics" ;
	//graphics_path = graphics_path.substring(0,graphics_path.lastIndexOf("/"));
	//graphics_path = graphics_path.substring(graphics_path.indexOf(".com/")+4);

	graphics_path = "../../image/wealth_mgmt";

	graphics_init = 1 ;
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
      	a.disabled = false;
	  }
    }
  }

  pressButton(title);
}

function unpressButton(which) {
	if ( graphics_init == 0 )
		{ init_path() }
	document.getElementById(which).src = graphics_path + "/" + which + ".gif";
}

switchButtons = ["default", "medium", "large"];

function pressButton(which) {

	graphics_init = 0;

	if ( graphics_init == 0 )
	{ 
		init_path() 
	}

	for (i = 0; i < switchButtons.length; i++) 
	{
		if (which == switchButtons[i]) {
			document.getElementById(which).src = graphics_path + "/" + which + "_p.gif";
		} else {
			document.getElementById(switchButtons[i]).src = graphics_path + "/" + switchButtons[i] + ".gif";
		}
	}

	if (which == "null") {
		document.getElementById("default").src = graphics_path + "/default_p.gif";
	}

}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) {
    	return a.getAttribute("title");
    }
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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 {
  	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;
}

window.onload = function(e) {
  if ( graphics_init == 0 )
    { init_path() }
  smallpressed = new Image();
  smallpressed.src = graphics_path + "/default_p.gif"
  medpressed = new Image();
  medpressed.src = graphics_path + "/medium_p.gif"
  largepressed = new Image();
  largepressed.src = graphics_path + "/large_p.gif"
  if (document.getElementById) {
    var cookie = readCookie("ocbc_wm_style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);
    }
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("ocbc_wm_style", title, 365);
}

function newwindow() 
{ 
	window.open('http://www.ocbc.com/wealth_mgmt/tools/calculator/calculator.html','jav','width=550, height=400, location=no, toolbar=no, menubar=no, scrollbars=no, resizable=no'); 

} 