var thisbrowser = msieversion();

if ( thisbrowser >= 7)
	//This is Internet Explorer > 7
	document.write ( "<link rel=\"stylesheet\" href=\"inc/cpa.css\" type=\"text/css\" media=\"screen\">" );
else if ( thisbrowser >= 4)
	//This is Internet Explorer less than 7 and greater than 4
	document.write ( "<link rel=\"stylesheet\" href=\"inc/cpa_oldie.css\" type=\"text/css\" media=\"screen\">" );
else if ( thisbrowser >= 3 )
	//This is Internet Explorer 3
	document.write ( "<link rel=\"stylesheet\" href=\"inc/cpa_oldie.css\" type=\"text/css\" media=\"screen\">" );
else
	//This is another browser
	document.write ( "<link rel=\"stylesheet\" href=\"inc/cpa.css\" type=\"text/css\" media=\"screen\">" );

function scrollto(id1,id2)
{
if (thisbrowser == 0 || thisbrowser >= 7)
{ 
	coordinates_1 = getAnchorPosition(id1);
	coordinates_2 = getAnchorPosition(id2);
	var ypos_1 = coordinates_1.y;
	var ypos_2 = coordinates_2.y;
	var scrollpos = parseInt(ypos_2 - ypos_1);
	//alert("id1: "+id1);
	//alert("id2: "+id2);
	//alert("scrollpos: "+scrollpos);
	
	window.scroll(0,scrollpos); // horizontal and vertical scroll targets
}
}

function eheightonresize(id)
{
if ( thisbrowser > 0)
{ 
  var myWidth = 0, myHeight = 0;
  var myWidth1 = 0, myHeight1 = 0;
  var diff = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth1 = window.innerWidth;
    myHeight1 = window.innerHeight;
	// do nothing...
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
		if (msieversion() >= 7)
		{
    		myWidth1 = window.innerWidth;
    		myHeight1 = window.innerHeight;
			// do nothing else...
		}
		else
		{
    		myWidth = document.documentElement.clientWidth;
    		myHeight = document.documentElement.clientHeight;
		}
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(myHeight > 0)
  {
  	var new_h = myHeight - 140;
	document.getElementById(id).style.height=new_h;
	document.getElementById("navbar").style.height = myHeight - 89;

  }
  if(myWidth > 0)
  {
  	if(document.getElementById("contentframe"))
	{
		var new_w = myWidth - 325;
		document.getElementById("contentframe").style.width=new_w;
	}

  }
}
}

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}
function processItem(key){
if(queryString(key)=='false') 
{
// do nothing
//alert("you didn't enter a querystring item.");
}else{
//alert(queryString(key));
scrollto('content',queryString(key));
}
}

function WM_preloadImages() {

  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      document.WM.loadedImages[arg] = new Image();
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

icon = new Array();
function init(CurPg)
{
   var page = CurPg;

   icon["Resc"]  = "img/icon_resources.gif";
   icon["Dates2"]  = "img/icon_datestoremem.gif";
   icon["FAQ"]     = "img/icon_faqs.gif";
   icon["FinCal"]  = "img/icon_calculator.gif";
   icon["GetUs"]   = "img/icon_contactus.gif";
   icon["HomePg"]  = "img/icon_home.gif";
   icon["News"]  = "img/icon_newsletter.gif";
   icon["Links"]   = "img/icon_links.gif";
   icon["OurFirm"] = "img/icon_ourfirm.gif";
   icon["PriPol"]  = "img/icon_privacy.gif";
   icon["Service"] = "img/icon_ourservices.gif";

   document.getElementById("icon").src = icon[CurPg];
}
