/* Abrir Popup Termos de Uso e FAQ*/
function showWindow(janela) {
    if(janela == 'termos') {
        window.open("showTermos.html","termos","width=450,height=350,scrollbars=yes");
    } else if (janela == 'faq') {
        window.open("showFaq.html","faq","width=450,height=350,scrollbars=yes");
    }
}

/* ------------------------------------------------------------
   Maintains the query string. Used to sublink into the site
   ------------------------------------------------------------ */
var queryVars = new Object();
var qloc = "";

function parseQuery( p_qstr ) {
	var pairHalves;
	var queryVars = {};
	var N_V_pairs = p_qstr.split("&");
	var l = N_V_pairs.length;
	for(i=0; i<l; i++){
		pairHalves = N_V_pairs[i].split("=");
		queryVars[pairHalves[0]] = pairHalves[1];
		for(d=2;d<pairHalves.length;d++) {
			queryVars[pairHalves[0]] += "=" + pairHalves[d];
		}
	}
	return queryVars;
}

function buildQString( p_queryVars )
{
	var results = "";
	for( var item in p_queryVars ){
		if ( results.length > 0 )
		{
			results += "&";
		}
		if ( item.length > 0 )
		{
			results += item + "=" + p_queryVars[ item ];
		}
	}
	
	return results;
}

function cleanupQString( p_qString )
{
	if( p_qString && p_qString != null && p_qString != "" ) {
	
		if( q_str.indexOf(";") > -1 ) {
			var temp_q_str = p_qString ;
			p_qString = temp_q_str.substring( 0, p_qString.indexOf(";") );
		}
		
		// remove the question mark
		p_qString = p_qString.substring( 1 );
	
	} else {
		p_qString = "";
	}
	
	return p_qString;
}

/* ------------------------------------------------------------
   Used for resizing objects when dealing with 100% Flash movies
   ------------------------------------------------------------ */

function getWinSize()
{
	var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' )
      {
         //Non-IE
         myWidth = window.innerWidth;
         myHeight = window.innerHeight;
      }
      else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
      {
          //IE 6+ in 'standards compliant mode'
          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;
      }
      return {w:myWidth,h:myHeight}
      
}   
   
function adjustObjectSize(id,w,h)
{
      var winSizes = getWinSize();
      
      var tmpObject = document.getElementById(id);

      if(winSizes.w < w)
      {
         tmpObject.style.width = w + "px";
      }
      else
      {
         tmpObject.style.width = "100%";
      }
      if(winSizes.h < h)
      {
         tmpObject.style.height = h + "px";
      }
      else
      {
         tmpObject.style.height = (winSizes.h)-2 + "px";
      }
}

/* ------------------------------------------------------------
   Used for getting the users browser
   ------------------------------------------------------------ */

// browser detection
var _appName = navigator.appName;
var _appVersion = navigator.appVersion;
var _userAgent = navigator.userAgent.toLowerCase();

function getBrowser() {
      
      var browser = '';
      
      if ((_appName.indexOf('Microsoft') != -1) && (_userAgent.indexOf('mac') == -1)) {
		  browser = 'IE';
	  // We're treating MAC IE as a special case anymore
	  } else if ((_appName.indexOf('Microsoft') != -1) && (_userAgent.indexOf('mac') != -1)) {		
	      browser = 'Other';
	  } else if (_userAgent.indexOf('safari') != -1) {
		  browser = 'Safari';
	  } else if (_userAgent.indexOf('firefox') != -1) {
		  browser = 'Firefox';
	  } else {
		  browser = 'Other';
	  }
	  return browser;
}
