// JavaScript Document
try {
	var currentPage = document.body.id
	// this means the user is coming straight to pro web site or coming to pro site though pictage.com
	// if the user is coming through pictage.com then we have to show pictage.com top menu
	// else we show pro site top menu
	if( parent.tophdr == 'undefined' || parent.tophdr == null) {
		// show pro site top menu
		// but do not show this navigation - if the user in under Community tab
		//if(currentPage != 'community') {
			document.write('<!--<div id="header"><h1><a href="../index.html" title="Home">Pictage</a></h1><div id="topnav2"><ul><li id="nav_prohome"><a href="../index.html" id="current" title="Pictage Pro Home"><span>Welcome</span></a></li><li id="nav_products"><a href="../products.shtml" title="Products & services currently offered by Pictage"><span>Products</span></a></li><li id="nav_community"><a href="../community/index.html" title="Pictage community website and forums"><span>Community</span></a></li><li id="nav_support"><a href="../photog_help.htm" title="Pictage support, instructional guides and videos"><span>Support</span></a></li><li id="nav_home"><a href="http://www.pictage.com" id="current" title="Pictage Studio Home"><span>Studio Home</span></a></li></ul><div id="adminlink">New member? <a href="../getting_started.htm" title="Learn how to get started with Pictage!">Get started</a></div></div></div>--><div id="header"><h1><a href="http://www.pictage.com/" title="Pictage Studio Home">Pictage</a></h1><div id="topnav2"><ul><li id="nav_home"><a href="http://www.pictage.com" title="Pictage Studio Home"><span>Studio Home</span></a></li><li id="nav_prohome"><a href="../index.html" title="Products & services currently offered by Pictage"><span>Products & Services</span></a></li><li id="nav_community"><a href="../community/index.html" title="Pictage community website and forums"><span>Community</span></a></li><li id="nav_myfolders"><a href="http://www.pictage.com" title="My Folders - Accessible from Studio Home"><span>My Folders</span></a></li><li id="nav_support"><a href="../photog_help.htm" title="Pictage support, instructional guides and videos"><span>Support</span></a></li></ul><div id="adminlink">New member? <a href="../getting_started.htm" title="Learn how to get started with Pictage!">Get started</a></div></div></div>');
//		}
	} else {
	
		// show pictage.com top menu
		
		// check the referring URL.
		// if it had studio_info.xml as part of the URL, then the user is coming from Studio Home or My Folders.
		// 	put that url in cookie for future reference.
		// else the user is coming from one of the internal links of pro site.
		//	get the url from cookie and call synPictageTopNav().
		var docRef = document.referrer;
	    	if(docRef.match('get_studio_info.xml') != null) {
		} else {
			synPictageTopNav();
		}
	}
    } catch(err) {	alert(err); 	}

//
// This function will make sure the top menu is in sync with body id.
//
function synPictageTopNav() {
	var currentPage = document.body.id
	// replace studio_manager with studio_header
    	if(currentPage == null || currentPage == '') {
		parent.tophdr.keepIn('Support');
    	} else {

		if(currentPage == 'products' || currentPage == 'home') {
			parent.tophdr.keepIn('ProductsServices');
		}

		// community
		if(currentPage == 'community') {
			parent.tophdr.keepIn('Community');
		}

		// support
		if(currentPage == 'support') {
			parent.tophdr.keepIn('Support');
		}
	}
	setProSiteCookie(86400);
}

//
// To refresh the menu with the tab selection.
//
function replaceCurrentTabParameter(newNavFrameURL, param) {
	var indexOfCT = newNavFrameURL.indexOf('currentTab=');
	var tempremaindingURL = newNavFrameURL.substr(indexOfCT, newNavFrameURL.length);
	var remaindingURL = tempremaindingURL.substr(tempremaindingURL.indexOf('&'), tempremaindingURL.length);
	var finalURL = newNavFrameURL.substr(0 , indexOfCT);
	finalURL += param;
	finalURL += remaindingURL;
	return finalURL;
}

//
// Utility method to get a parameter value from the url
//
function getURLParam(strParamName, strHref){
	var strReturn = "";
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return unescape(strReturn);
} 

