function trim(stringToTrim)
{ return stringToTrim.replace(/^\s+|\s+$/g,"");}
// JavaScript Document
function validate_email(){
	var email = trim(document.getElementById("email").value);
	// Check email Id
	if(!checkEmail(trim(email.value))){
		email.focus();
		return false;
	}
}
// Function for form validation
function validate_form(){
var name = document.getElementById("fullName");
var email = document.getElementById("email");
var phone = document.getElementById("phone");
var subject = document.getElementById("subject");
var city = document.getElementById("city");
var occupation = document.getElementById("occupation");
//check name for blank values 
if(trim(name.value) == ""){
//alert("Please, Enter your Name!");
document.getElementById("firstNameErrMsgSpan").innerHTML = 'Please, Enter your Name!';
document.getElementById("fullName").style.border = "1px solid #FF0000";
name.focus();
return false;
} else {
document.getElementById("firstNameErrMsgSpan").innerHTML = '';
document.getElementById("fullName").style.border = "1px solid #000000";
}
// Check email Id
if(!checkEmail(trim(email.value))){
email.focus();
return false;
}
//check name for blank values 
if(trim(phone.value) == ""){
//alert("Please, Enter Proper Phone No!");
document.getElementById("phoneErrMsgSpan").innerHTML = 'Please, Enter Proper Phone No!';
document.getElementById("phone").style.border = "1px solid #FF0000";
phone.focus();
return false;
} else {
document.getElementById("phoneErrMsgSpan").innerHTML = '';
document.getElementById("phone").style.border = "1px solid #000000";
}
//check phone No for character
if(!IsInteger(trim(phone.value))){
//alert("Please, Enter only numeric value");
document.getElementById("phoneErrMsgSpan").innerHTML = 'Please, Enter only numeric value!';
document.getElementById("phone").style.border = "1px solid #FF0000";
phone.focus();
return false;
} else {
document.getElementById("phoneErrMsgSpan").innerHTML = '';
document.getElementById("phone").style.border = "1px solid #000000";
}
//check name for blank values 
if(trim(subject.value) == ""){
//alert("Please, Enter Proper Phone No!");
document.getElementById("subjectErrMsgSpan").innerHTML = 'Please, Enter the Subject!';
document.getElementById("subject").style.border = "1px solid #FF0000";
subject.focus();
return false;
} else {
document.getElementById("subjectErrMsgSpan").innerHTML = '';
document.getElementById("subject").style.border = "1px solid #000000";
}

//check name for blank values 
if(trim(city.value) == ""){
//alert("Please, Enter Proper Phone No!");
document.getElementById("cityErrMsgSpan").innerHTML = 'Please, Enter your City!';
document.getElementById("city").style.border = "1px solid #FF0000";
city.focus();
return false;
} else {
document.getElementById("cityErrMsgSpan").innerHTML = '';
document.getElementById("city").style.border = "1px solid #000000";
}

//check name for blank values 
if(trim(occupation.value) == ""){
//alert("Please, Enter Proper Phone No!");
document.getElementById("occupationErrMsgSpan").innerHTML = 'Please, Select your Occupation!';
document.getElementById("occupation").style.border = "1px solid #FF0000";
occupation.focus();
return false;
} else {
document.getElementById("occupationErrMsgSpan").innerHTML = '';
document.getElementById("occupation").style.border = "1px solid #000000";
}

}
// Function for checking Email id
function checkEmail(email){
if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){
document.getElementById("emailErrMsgSpan").innerHTML = '';
document.getElementById("email").style.border = "1px solid #000000";
return true;
}else {
//alert("Please Enter valid E-mail Id");
document.getElementById("emailErrMsgSpan").innerHTML = 'Please Enter valid E-mail Id!';
document.getElementById("email").style.border = "1px solid #FF0000";
return false;
}
}
// Function for checking phone no.
function IsInteger(no){
var i;
for(i=0 ; i < no.length; i++){
var c= no.charAt(i);
if((( c < "0") || (c > "9")))
return false;
}
return true;
}
//var base_url="http://ppfas.managedns.org/ppfas/";
var server_path_for_images = 'http://www.ppfas.com/'; /** Local Path **/
var theImages = new Array()
//Random-loading images
theImages[0] = server_path_for_images+'site-images/caricatures/a-public-opinion.png?20110609'
theImages[1] = server_path_for_images+'site-images/caricatures/be-fearful.png?20110609'
theImages[2] = server_path_for_images+'site-images/caricatures/dont-save-what-is.png?20110609'
theImages[3] = server_path_for_images+'site-images/caricatures/dont-sepnd.png?20110609'
theImages[4] = server_path_for_images+'site-images/caricatures/holding-period.png?20110609'
theImages[5] = server_path_for_images+'site-images/caricatures/if-a-business-does-well.png?20110609'
theImages[6] = server_path_for_images+'site-images/caricatures/if-you-buy-things.png?20110609'
theImages[7] = server_path_for_images+'site-images/caricatures/its-not-you-salary.png?20110609'
theImages[8] = server_path_for_images+'site-images/caricatures/markets-are-inefficient.png?20110609'
theImages[9] = server_path_for_images+'site-images/caricatures/pre-pone.png?20110609'
theImages[10] = server_path_for_images+'site-images/caricatures/retirement.png?20110609'
theImages[11] = server_path_for_images+'site-images/caricatures/rule.png?20110609'
theImages[12] = server_path_for_images+'site-images/caricatures/smart-people.png?20110609'
theImages[13] = server_path_for_images+'site-images/caricatures/the-best-time.png?20110609'
theImages[14] = server_path_for_images+'site-images/caricatures/time-is-the-enemy.png?20110609'
theImages[15] = server_path_for_images+'site-images/caricatures/you-pay-a-very-high-price.png?20110609'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
if(whichImage==0){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=162 height=292>');}
else if(whichImage==1){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=191 height=325>');}
else if(whichImage==2){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=162 height=325>');}
else if(whichImage==3){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=168 height=325>');}
else if(whichImage==4){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=160 height=274>');}
else if(whichImage==5){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=178 height=298>');}
else if(whichImage==6){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=162 height=325>');}
else if(whichImage==7){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=166 height=325>');}
else if(whichImage==8){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=162 height=325>');}
else if(whichImage==9){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=190 height=325>');}
else if(whichImage==10){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=180 height=325>');}
else if(whichImage==11){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=194 height=325>');}
else if(whichImage==12){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=191 height=325>');}
else if(whichImage==13){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=181 height=325>');}
else if(whichImage==14){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=191 height=325>');}
else if(whichImage==15){
document.write('<img src="'+theImages[whichImage]+'" border=0 width=178 height=295>');}
}
/************************ Show Hide FAQs for Financial Planning*********************///
function show_hide_fp(id) {
    if(id != 'undefined'){
	//alert(document.getElementById(id).style.display);  // DEBUG
	   if(document.getElementById(id).style.display == ''){
		  allNone(id,false);
       } else {
	   	  allNone(id,true);
	   } 
    }
}
// Using for display all div to none
function allNone(id,displayId){
document.getElementById('1').style.display = 'none';document.getElementById('2').style.display = 'none';document.getElementById('3').style.display = 'none';document.getElementById('4').style.display = 'none';document.getElementById('5').style.display = 'none';document.getElementById('6').style.display = 'none';document.getElementById('7').style.display = 'none';document.getElementById('8').style.display = 'none';document.getElementById('9').style.display = 'none';document.getElementById('10').style.display = 'none';document.getElementById('11').style.display = 'none';document.getElementById('12').style.display = 'none';document.getElementById('13').style.display = 'none';document.getElementById('14').style.display = 'none';document.getElementById('15').style.display = 'none';document.getElementById('16').style.display = 'none';document.getElementById('17').style.display = 'none';document.getElementById('18').style.display = 'none';document.getElementById('19').style.display = 'none';document.getElementById('20').style.display = 'none';document.getElementById('21').style.display = 'none';
if(displayId == true){
document.getElementById(id).style.display = '';
	}
}

/*********** Banner Slideshow*******************/
var gblPhotoShufflerDivId = "photodiv";
var gblPhotoShufflerImgId = "photoimg"; 
var gblImg = new Array(
"http://www.ppfas.com/site-images/banners/banner-1.jpg",     
"http://www.ppfas.com/site-images/banners/banner-2.jpg",    
"http://www.ppfas.com/site-images/banners/banner-3.jpg", 	
"http://www.ppfas.com/site-images/banners/banner-4.jpg");
  var gblPauseSeconds = 6;
  var gblFadeSeconds = .75;
  var gblRotations = 50;
  // End Customization section
  var gblDeckSize = gblImg.length;
  var gblOpacity = 100;
  var gblOnDeck = 0;
  var gblStartImg;
  var gblImageRotations = gblDeckSize * (gblRotations+1);
  window.onload = photoShufflerLaunch;
  function photoShufflerLaunch()
  {
  	var theimg = document.getElementById(gblPhotoShufflerImgId);
        gblStartImg = theimg.src; // save away to show as final image
	document.getElementById(gblPhotoShufflerDivId).style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
	setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
  }
  function photoShufflerFade()
  {
  	var theimg = document.getElementById(gblPhotoShufflerImgId);
  	// determine delta based on number of fade seconds
	// the slower the fade the more increments needed
        var fadeDelta = 100 / (30 * gblFadeSeconds);
	// fade top out to reveal bottom image
	if (gblOpacity < 2*fadeDelta ) 
	{
	  gblOpacity = 100;
	  // stop the rotation if we're done
	  if (gblImageRotations < 1) return;
	  photoShufflerShuffle();
	  // pause before next fade
          setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
	}
	else
	{
	  gblOpacity -= fadeDelta;
	  setOpacity(theimg,gblOpacity);
	  setTimeout("photoShufflerFade()",30);  // 1/30th of a second
	}
  }

  function photoShufflerShuffle()
  {
	var thediv = document.getElementById(gblPhotoShufflerDivId);
	var theimg = document.getElementById(gblPhotoShufflerImgId);
	
	// copy div background-image to img.src
	theimg.src = gblImg[gblOnDeck];
	// set img opacity to 100
	setOpacity(theimg,100);

        // shuffle the deck
	gblOnDeck = ++gblOnDeck % gblDeckSize;
	// decrement rotation counter
	if (--gblImageRotations < 1)
	{
	  // insert start/final image if we're done
	  gblImg[gblOnDeck] = gblStartImg;
	}

	// slide next image underneath
	thediv.style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
  }

  function setOpacity(obj, opacity) {
    opacity = (opacity == 100)?99.999:opacity;
    
    // IE/Win
    obj.style.filter = "alpha(opacity:"+opacity+")";
    
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity/100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity/100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity/100;
  }
/********* Banner*****************/
//****************************** Research Supscription ****************************//
var icpForm4257 = document.getElementById('icpsignup4257');
if (document.location.protocol === "https:")
icpForm4257.action = "https://app.icontact.com/icp/signup.php";
function verifyRequired4257() {
  if (icpForm4257["fields_email"].value == "") {
    icpForm4257["fields_email"].focus();
    alert("The Enter Your Email field is required.");
    return false;
  }
return true;
}

// Scrolling sidebar for your website
// Downloaded from Marcofolio.net
// Read the full article: http://www.marcofolio.net/webdesign/create_a_sticky_sidebar_or_box.html

window.onscroll = function()
{
	if( window.XMLHttpRequest ) {
		if (document.documentElement.scrollTop > 300 || self.pageYOffset > 300) {
			$('content').style.position = 'fixed';
			$('content').style.top = '0';
		} else if (document.documentElement.scrollTop < 300 || self.pageYOffset < 300) {
			$('content').style.position = 'absolute';
			$('content').style.top = '300px';
		}
	}
}

/* iContact Form for FREE PMS Guide on website*/
var icpForm4688 = document.getElementById('icpsignup4688');

if (document.location.protocol === "https:")

	icpForm4688.action = "https://app.icontact.com/icp/signup.php";
function verifyRequired4688() {
  if (icpForm4688["fields_email"].value == "") {
    icpForm4688["fields_email"].focus();
    alert("The Email field is required.");
    return false;
  }
  if (icpForm4688["fields_fname"].value == "") {
    icpForm4688["fields_fname"].focus();
    alert("The First Name field is required.");
    return false;
  }
  if (icpForm4688["fields_phone"].value == "") {
    icpForm4688["fields_phone"].focus();
    alert("The Phone field is required.");
    return false;
  }
return true;
}
