// JavaScript Document

function getPage(pageName)
{
  var page = pageName;
  if(!page) page = "home";
  var xmlhttp=false; //Clear our fetching variable
  try {
        xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object
       } 
  catch (e) 
    {
      try 
	    {
          xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
        } 
		catch (E) 
		  {
            xmlhttp = false;
          }
     }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
    {
      xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
    }	
  var file = 'pages/' + page + '.inc.php'; //This is the path to the file that displays the page *
  xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
  xmlhttp.onreadystatechange=function() 
	 {
      if (xmlhttp.readyState==4)  //Check if it is ready to recieve data
        {      
		 var content = xmlhttp.responseText; //The content data which has been retrieved ***
         if( (content) )  //Make sure there is something in the content variable
		   {
			document.getElementById('left_column').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
			sIFR.replace(microgramma, {
  			  selector: '#left_column h1',
  			  css: {'.sIFR-root' : { 'color': '#FF0000' }}
			});
			sIFR.replace(microgramma, {
  			  selector: '#left_column h2',
  			  css: {'.sIFR-root' : { 'color': '#0000FF' }}
			});
			sIFR.replace(microgramma, {
  			  selector: '#left_column h3',
  			  css: {'.sIFR-root' : { 'color': '#006600' }}
			});
			FadeIn('left_column');
           }
	    }
      }
  xmlhttp.send(null) //Nullify the XMLHttpRequest
  return;
}


/* Load sifr for home page */
function loadHomeSifr()
 {
	 sIFR.replace(microgramma, {
  			  selector: '#left_column h1',
  			  css: {'.sIFR-root' : { 'color': '#FF0000' }}
			});
 }


/*
Javascript: display_functions.js
Contains functions used for display purposes (show/hide, animate, etc.)

Author: John McClumpha - http://blogs.igeek.com.au/DarkAz/ - darkaz75@gmail.com
Updated: 06/02/07

If you wish to use this code on a website, feel free 
- all I ask is for a quick email with a URL where they can be seen so I can see where/how they are being used :)

*/


// Function used to show/hide the target div
function ToggleDiv($WhichDiv) {
	if (document.getElementById($WhichDiv).style.display == "none") {
		setOpac($WhichDiv,100); // set it to opaque (just in case)
		document.getElementById($WhichDiv).style.display = "block";
	} else {
		document.getElementById($WhichDiv).style.display = "none";
	}
}

// Function used to show/hide the target div utilizing fade effects below
function FadeToggleDiv($WhichDiv) {
	if (document.getElementById($WhichDiv).style.display == "none") {
		FadeIn($WhichDiv);
	} else {
		FadeOut($WhichDiv);
	}
}

// Function used to fade "in" a div
function FadeIn($WhichDiv) {
	setOpac($WhichDiv,0); // set it to transparent
	document.getElementById($WhichDiv).style.display = "block"; // display as block just in case
	for( var i = 0 ; i <= 100 ; i++ ) {
		   setTimeout( 'setOpac(\''+$WhichDiv+'\',' + i + ')' , 8 * i );
	}
}

// Function used to fade "out" a div
function FadeOut($WhichDiv) {
	for( var i = 0 ; i <= 100 ; i++ ) {
		   setTimeout( 'setOpac(\''+$WhichDiv+'\',' + (100 - i) + ')' , 8 * i );
	}
	setTimeout('ToggleDiv(\''+$WhichDiv+'\')', 8 * i);
	setOpac($WhichDiv,100); // set it to opaque (just in case)
}

// Function used to set the opacity of a div (from 0 to 10)
function setOpac( $WhichDiv, value ) {
	document.getElementById($WhichDiv).style.opacity = value / 100;
	document.getElementById($WhichDiv).style.filter = 'alpha(opacity=' + value + ')';
}


// Function used to shrink/grow a div vertically
function ToggleVert($WhichDiv, $MinHeight, $MaxHeight) {
	var $CurrHeight = parseInt(document.getElementById($WhichDiv).style.height);
	if ($CurrHeight < ($MaxHeight - 10)) {
		VertScale($WhichDiv,$MaxHeight);
	} else {
		VertScale($WhichDiv,$MinHeight);
	}
}

// Function used to animate the scaling of a div vertically
function VertScale($WhichDiv, $EndHeight) {
	var $StartHeight = parseInt(document.getElementById($WhichDiv).style.height);
	document.getElementById($WhichDiv).style.display = "block"; // display as block just in case
	document.getElementById($WhichDiv).style.overflow = 'hidden'; // set the overflow to hidden
	for( var i = 0 ; i <= 50 ; i++ ) {
		   $CurrHeight = ($StartHeight - ((($StartHeight - $EndHeight) / 50) * (i-1)));
		   setTimeout( 'setHeight(\''+$WhichDiv+'\',' + $CurrHeight + ')' , 8 * i );
	}
	if ($EndHeight == 0) {
		setTimeout('ToggleDiv(\''+$WhichDiv+'\')', 8 * i);
	}
}

// Function used to set the height of a div
function setHeight( $WhichDiv, value ) {
	document.getElementById($WhichDiv).style.height = parseInt(value) + "px";
}



/* Text pulsation */
function setOpacity(level) {
  document.getElementById('fade_text').style.opacity = level;
  document.getElementById('fade_text').style.MozOpacity = level;
  document.getElementById('fade_text').style.KhtmlOpacity = level;
  document.getElementById('fade_text').style.filter = "alpha(opacity=" + (level * 100) + ");";
}

var duration = 1000;  /* 1000 millisecond fade = 1 sec */
var steps = 20;       /* number of opacity intervals   */
var delay = 1000;     /* 1 sec delay before fading out */

function fadeIn(){
  for (i = 0; i <= 1; i += (1 / steps)) {
    setTimeout("setOpacity(" + i + ")", i * duration);
  }
  setTimeout("fadeOut()", delay);
}

function fadeOut() {
  for (i = 0; i <= 1; i += (1 / steps)) {
    setTimeout("setOpacity(" + (1 - i) + ")", i * duration);
  }
  setTimeout("fadeIn()", duration);
}

//window.onload = fadeOut();

function popitup(url) {
	newwindow=window.open(url,'name','height=580,width=829,top=100,left=20,titlebar=no,toolbar=no,location=no');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popitupscroll(url) {
	newwindow=window.open(url,'name','height=580,width=829,top=100,left=20,titlebar=no,toolbar=no,location=no,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}


/* PayPal Fee Calculator */

function PayPalFeeCalc() {
	var amountField = document.getElementById('amount');
	var submitAmountField = document.getElementById('submitAmount');
	var amount = amountField.value - 0;
	var tierOne = 0.024; /*Percentage added to initial value for $0 to $5000*/
	var tierTwo = 0.02; /*Percentage added to initial value for $5000 to %15000*/
	var flatRate = 0.30; /*30 cents added to each transaction */
	var tierOneRange = 5000; /* Tier One - $0 - $5000 */
	var tierTwoRange = 15000; /* Tier Two - $5000 - $15000 */
	
	if (amount <= tierOneRange) {
		amount = amount + (amount * tierOne) + flatRate;
	} 
	else if ( (amount > tierOneRange) && (amount < tierTwoRange) ) {
		amount = amount + (amount * tierTwo) + flatRate;
	}
	finalAmount = Math.round(amount*100)/100;
	document.getElementById('paypal_amount_calcuated').innerHTML = '$' + finalAmount;
	document.getElementById('submitAmount').value = 0 + finalAmount;
}

