// JavaScript Document
var M_IN_STOCK 			= "IN_STOCK";
var M_IN_STOCK_RETAIL	= "IN_STOCK_RETAIL";
var M_BACKORDERED	= "BACKORDERED";
var M_OUT_OF_STOCK	= "OUT_OF_STOCK";
var M_iMouseX		= 0;
var M_iMouseY		= 0;
var M_strGFileName	= "global.js";
var M_bIsDropdownHidden	= false;
var M_bMenuItemShow 	= false;
var M_bIsPFWOpen 		= false;
var BrowserInfo 		= new BrowserDetect2();

// Track mouse position
SetTimeout( "document.onmousemove = GetMousePosition;", 1 );

// disallow the page to be framed
if (window.self != window.top) {
	try {
		top.location.replace( window.location.pathname );
	}
	catch( e ) {
		HandleError( "unframe window", e, M_strGFileName );
	}
}

function IniHome(){
	if(img_number=GetCookie("img_number")){
		img_number++;
		if(img_number>3)
			img_number=1;
	}	
	else
		img_number=1;
	document.getElementById("img_home").src="imagenes/home" + img_number + ".jpg";
	SetCookie("img_number",img_number);
}

function LoadPage() {       
			try {
	  // quit if this function has already been called
			if (arguments.callee.done) return;
			  InitializeTopNav('');
				// flag this function so we don't do the same thing twice
				arguments.callee.done = true;
        }
        catch( e ) {
          HandleError( "LoadPage", e );
        }
      
      
	/* for Mozilla */
	if (document.addEventListener && (!/WebKit/i.test(navigator.userAgent)) ) {
		document.addEventListener("DOMContentLoaded", LoadPage, null);
	}
	}
	/* Safari 
	if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            LoadPage(); // call the onload handler
        }
    }, 10);
	}*/

   // for Internet Explorer (using conditional comments)
	/*@cc_on @*/
	/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
			if (this.readyState == "complete") {
				LoadPage(); // call the onload handler
			}
	};
	/*@end @*/



function chr(c) {
	var h = c . toString (16);
	h = unescape ('%'+h);
	return h;
}

function extension(str_filename){
	var i = str_filename.length;
	var slicer = String(slicer)
	var ext = String('')
	do{ 
		slicer = str_filename.slice(i-1,i);
		ext = slicer+ext
		i--
	} 
	while(slicer != '.' && i > 1)
	
	ext = ext.toLowerCase();
	return(ext);
}

//funcion encargada de crear el objeto
 function obj_ajax() {         
	try {                 
		 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e) {                 
		 try {                          
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		 catch (E) {                           
			 xmlhttp = false;}
         }
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {                 
 		xmlhttp = new XMLHttpRequest(); }
  return xmlhttp
 }

function addFileInput( elem ) {
		if ( false != elem )
		{
			filepath = elem.value.split("\\");
			filename = filepath[filepath.length-1];
			extensionpath = filename.split(".");
			extension = extensionpath[extensionpath.length-1];
		 	if( !extension.match(/(jpg)|(jpeg)|(gif)|(png)/) )
			{
				alert ( "Sólo se permite subir imágenes: jpg, gif y png" );
				return false;
			}
			$(elem).hide();
			$("#file_list").append("<li style='display:none'>&bull; "+filename+" <a href='javascript:;' onclick='delFile(this,"+($("#file_list li").size()+1)+")' style='color:red'>[x]</small></a></li>\n");
			$("#file_list li:last").slideDown("slow");
		}
		$("#Submit").get(0).disabled = false;
		$("#file_inputs").append('<input name="file'+($("#file_list li").size()+1)+'" type="file" id="file'+($("#file_list li").size()+1)+'" size="35" onChange="addFileInput(this);"  class="input">\n');

}

function delFile ( el, file )
{
	$(el.parentNode).remove();
	$("#file"+file).remove();
}

function Resize(){
try{

    var frameWidth;
    var frameHeight;
    var obj;

    if (self.innerWidth){
      frameWidth = self.innerWidth;
      frameHeight = self.innerHeight;
    }else if (document.documentElement && document.documentElement.clientWidth){
      frameWidth = document.documentElement.clientWidth;
      frameHeight = document.documentElement.clientHeight;
    }else if (document.body){
      frameWidth = document.body.clientWidth;
      frameHeight = document.body.clientHeight;
    }else{
      return;
    }

    obj=document.getElementById("background_image");
    if ((obj)){
      // reset to default position on resize/load
      obj.style.top = obj.style.left = 0;
      var ratio = 1140/600;
      var ratio_width = frameHeight * ratio;
      if (ratio_width < frameWidth){
      }
      obj.style.height = frameHeight.toString() + "px";
      obj.style.width = ratio_width.toString() + "px";
      $('background_image').show();
    }
    
    }catch (e){
    }
}

function Resize_intro(){
try{

    var frameWidth;
    var frameHeight;
    var obj;

    if (self.innerWidth){
      frameWidth = self.innerWidth;
      frameHeight = self.innerHeight;
    }else if (document.documentElement && document.documentElement.clientWidth){
      frameWidth = document.documentElement.clientWidth;
      frameHeight = document.documentElement.clientHeight;
    }else if (document.body){
      frameWidth = document.body.clientWidth;
      frameHeight = document.body.clientHeight;
    }else{
      return;
    }
	
    obj=document.getElementById("miFlash");
    if ((obj)){
      // reset to default position on resize/load
      obj.style.top = obj.style.left = 0;
      var ratio = 1140/600;
      var ratio_width = frameHeight * ratio;
      if (ratio_width < frameWidth){
      }
    obj.style.height = frameHeight.toString() + "px";
    obj.style.width = frameWidth.toString() + "px";
	}
    
    }catch (e){
    }
}

function ResetForm(which){
var pass=true
var first=-1
if (document.images){
	for (i=0;i<document.getElementById(which).length;i++){
		var tempobj=document.getElementById(which).elements[i]
		 if (tempobj.type=="text"){
			  eval(tempobj.value="")
			  if (first==-1) {first=i}
		 }
		 else 
		 	if (tempobj.type=="checkbox") {
		  		eval(tempobj.checked=0)
		  		if (first==-1) {first=i}
		 }
		 else if (tempobj.col!="") {
		  	eval(tempobj.value="")
		 	 if (first==-1) {first=i}
		 }
	}
}
document.getElementById(which).elements[first].focus()
return;
}

/*-------------------------------------------------------------------
| LTrim(s)
| Devuelve una cadena sin los espacios del principio
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function LTrim(s){
	var i=0;
	var j=0;
	
	// Busca el primer caracter <> de un espacio
	for(i=0; i<=s.length-1; i++)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(j, s.length);
}

/*-------------------------------------------------------------------
| RTrim(s)
| Quita los espacios en blanco del final de la cadena
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function RTrim(s){
	var j=0;
	
	// Busca el último caracter <> de un espacio
	for(var i=s.length-1; i>-1; i--)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(0, j+1);
}

/*-------------------------------------------------------------------
| Trim(s)
| Quita los espacios del principio y del final
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function Trim(s){
	return LTrim(RTrim(s));
}

/*-------------------------------------------------------------------
| UCase(s)
| Devuelve la cadena convertida a mayúsculas
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function UCase(s){
	return s.toUpperCase();
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Cambiar_imgexp(img_id,img_filename,total_img) {
	 //Selecciono el item dado, y quito seleccion en los demas
	 for(i=1;i<=total_img;i++)
	 	document.getElementById("link_"+ i).className = "";
	 document.getElementById("link_"+ img_id).className = "selectedthumbs";
	 
	 document.getElementById("img_ampliacion").src="../imagenes/expediciones/" + img_filename;
}


/*
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function SetCookie( strName, strValue, strExpires, strPath, strDomain, bIsSecure ) {
    try {
		document.cookie = strName + "=" + escape( strValue ) +
        (( strExpires ) ? "; expires=" + new Date( strExpires ).toGMTString() : "") +
        (( strPath ) ? "; path=" + strPath : "") +
        (( strDomain ) ? "; domain=" + strDomain : "") +
        (( bIsSecure ) ? "; secure" : "");
				
		}
		catch( e ) {
			HandleError( "SetCookie", e, M_strGFileName );
		}
}


/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function GetCookie( strName ) {
    try {
			var dc = document.cookie;
			var strPrefix = strName + "=";
			var intBegin = dc.indexOf( "; " + strPrefix );
			if ( intBegin == -1 ) {
				 intBegin = dc.indexOf( strPrefix );
				 
				 if ( intBegin != 0 ) {
					 return null;
				 }
			} 
			else {
					intBegin += 2;
			}
			
			var strEnd = document.cookie.indexOf( ";", intBegin );
			if ( strEnd == -1) {
					strEnd = dc.length;
			}
			
			return unescape( dc.substring( intBegin + strPrefix.length, strEnd ));
		}
		catch( e ) {
			HandleError( "GetCookie", e, M_strGFileName );
		}
}

/**
 * Deletes the specified cookie.
 *
 * strName      name of the cookie
 * [strPath]    path of the cookie (must be same as path used to create cookie)
 * [strDomain]  domain of the cookie (must be same as domain used to create cookie)
 */
function DeleteCookie( strName, strPath, strDomain ) {
   try {
		 if ( getCookie( strName ) ) {
					document.cookie = strName + "=" +
							(( strPath ) ? "; path=" + strPath : "") +
							(( strDomain ) ? "; domain=" + strDomain : "") +
							"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		 }
	 }
	catch( e ) {
		HandleError( "DeleteCookie", e, M_strGFileName );
	}
}

function HandleError( strFunction, err, strFile ) {
  try {
		//var strMessage = "File: " + strFile + " - Function: " + strFunction + " - Message: " + err + ", " + err.description;
		//var objOmniture = new OmnitureHelper( strMessage );
		//objOmniture.logError(strMessage);
		alert( "Something is erroring:\n\nFile Name: " + strFile + "\nFunction Name: " + strFunction + "\nMessage: " + err + ", " + err.description + "\n\nRefreshing your browser window may fix things." );
	}
	catch( e ) {
		alert( "Something Is Erroring:\n\nFile Name: " + strFile + "\nFunction Name: " + strFunction + "\nMessage: " + err + ", " + err.description + "\n\nRefreshing your browser window may fix things." );
	}
}

/* Launches pop up window. */
function popUp( strURL, strWindowName, strFeatures ){
	try {
		new_window = window.open( strURL, strWindowName, strFeatures );
		new_window.focus();
	} // End try
	catch( e ) {
	 HandleError( "popUp", e, M_strGFileName );
	}
}

/* http://www.snook.ca/archives/000370.php - does what it says*/
function GetElementsByClassName( objNode, strClassname )
{
   var a = [];
	 try {
		
    var re = new RegExp('(^| )' + strClassname + '( |$)' );
    var els = objNode.getElementsByTagName("*");
    for(var i=0; i < els.length; i++) {
			if(re.test(els[i].className))a.push(els[i]);
		}
	 }
	 catch( e ) {
		 HandleError( "GetElementsByClassName", e, M_strGFileName );
	 }
	 
	 return a;
}

/* Gets the coordinates of the 'off' image and positions the 'on' image, on top of it. */
function PositionPopUpBox( strImgOff, strImgOn, strDiv ) {
	var objCoordinates;
	
	try {
		objCoordinates = GetLayerAdjustmentCoordinates( strImgOff, strImgOn, strDiv );
		
		SetObjectPosition( strDiv, objCoordinates.x, objCoordinates.y );
	}
	catch( e ) {
		HandleError( "PositionPopUpBox", e, M_strPageName );
	}
}
			

/* Generic method of deciding where we need to position the 'on' image. */
function GetLayerAdjustmentCoordinates( strImgOff, strImgOn, strDiv ) {
	var objImgOff, objImgOn, objDivLayer, objReturn;
	
	try {
		objImgOff 		= GetObjectPosition( strImgOff );
		objImgOn 			= GetObjectPosition( strImgOn );
		objDivLayer 	= GetObjectPosition( strDiv );
		objReturn = new Object();
		objReturn.x = 0;
		objReturn.y = 0;
		
		// Find the spread between where the off image is and where we want it to be
		if( objImgOff.x > objImgOn.x ) {
			objReturn.x = ( objDivLayer.x + ( objImgOff.x - objImgOn.x ) );
		}
		else {
			objReturn.x = ( objDivLayer.x - ( objImgOn.x - objImgOff.x ) );
		}
		
		if( objImgOff.y > objImgOn.y ) {
			objReturn.y = ( objDivLayer.y + ( objImgOff.y - objImgOn.y ) );
		}
		else {
			objReturn.y = ( objDivLayer.y - ( objImgOn.y - objImgOff.y ) );
		}
		
	}
	catch( e ) {
		HandleError( "GetLayerAdjustmentCoordinates", e, M_strPageName );
	}
	
	return objReturn;
}

/* This function gets all of the dropdown menus on the page and hides them.  On pages where
we may have layers that need to sit on top of dropdowns, we show and hide the dropdowns before we
show and hide the layer by overriding a function pointer. */
function HideDropdowns() {
	try {
		
		var objSelects = document.getElementsByTagName( "select" );
		for( var i=0; i < objSelects.length; i++ ) {
			ShowObject( objSelects[i], false );
		} // End For
		
		M_bIsDropdownHidden = true;
	}
	catch( e ) {
		HandleError( "HideDropdowns", e, M_strPageName );
	}
}


/* This function gets all of the dropdown menus on the page and shows them.  On pages where
we may have layers that need to sit on top of dropdowns, we show and hide the dropdowns before we
show and hide the layer by overriding a function pointer. */
function ShowDropdowns() {
	try {
		
		var objSelects = document.getElementsByTagName( "select" );
		for( var i=0; i < objSelects.length; i++ ) {
			ShowObject( objSelects[i], true );
		} // End for
		
		M_bIsDropdownHidden = false;
	}
	catch( e ) {
		HandleError( "ShowDropdowns", e, M_strPageName );
	}
}

/* Adds a bookmark.  Grabs the present URL/Title*/
function BookmarkPage( strProduct ) {
	try {
		var strTitle = "";
		
		if( strProduct != null && strProduct.length > 0 ) {
			var strNewProduct = strProduct.replace(/\*/g,"'");
			strTitle = document.title + ": " + strNewProduct;
		}
		else {
			strTitle = document.title;
		}
		
		if( window.external ) {
			window.external.AddFavorite( document.location.href, strTitle  );
		}
		else if( window.sidebar ) {
			window.sidebar.addPanel( strTitle, document.location.href, "" );
		}
		else {
			alert( "Sorry.  Your browser does not support this functionality." );
		}
	}
	catch( e ) {
		HandleError( "BookmarkPage", e, M_strGFileName );
	}
}

/* Gets the Y scroll position */
function GetScrollPositionY() {
	var intReturn = 0;
	try {
		 if ( document.all )
      {
         if ( !document.documentElement.scrollTop ) {
         	intReturn = document.body.scrollTop;
				 }
         else {
         	intReturn = document.documentElement.scrollTop;
				 }
      }   
      else
      {
		 		intReturn = window.pageYOffset;
			}
	}
	catch( e ) {
		HandleError( "GetScrollPositionY", e, M_strGFileName );
	}
	return intReturn;
}

/* Gets the X scroll position */
function GetScrollPositionX() {
	var intReturn = 0;
	try {
		 if ( document.all )
      {
         if ( !document.documentElement.scrollLeft ) {
         	intReturn = document.body.scrollLeft;
				 }
         else {
         	intReturn = document.documentElement.scrollLeft;
				 }
      }   
      else
      {
		 		intReturn = window.pageXOffset;
			}
	}
	catch( e ) {
		HandleError( "GetScrollPositionY", e, M_strGFileName );
	}
	return intReturn;
}


/* Gets the value of a dropdown element. */
function GetDropdownValue( element ) {
		var strValue, objElement;
		try {
			objElement = GetObject( element );
			
			strValue = objElement.options[ objElement.selectedIndex ].value;
		}
		catch( e ) {
				HandleError( "GetDropdownValue", e, M_strGFileName );
		}
		return strValue;
}

/* Takes a currency string and checks it for '$'.  If it finds them, it removes them. */
function ConvertCurrencyToNumber( strInput ) {
	var strReturn;
	
	try {
		strReturn =  strInput.toString().replace( /$|\,/g, '' );
		
		// Its not a number, return 0
		if ( isNaN( strReturn ) ) {
			strReturn = 0.00;
		}
		
	}
	catch( e ) {
		HandleError( "ConvertCurrencyToNumber", e, M_strGFileName );
	}
	
	return parseFloat( strReturn );
}


/* Takes a 'number' and formats it US dollar style */
function FormatCurrency( objAmount )
{
	var flAmount, strMinus, strAmount;
	try {
		var flAmount = parseFloat( objAmount );
		
		if( isNaN( flAmount ) ) {
			flAmount = 0.00;
		}
		
		strMinus = "";
		if( flAmount < 0 ) {
			strMinus = "-";
		}
		
		flAmount = Math.abs( flAmount );
		flAmount = parseInt( (flAmount + .005) * 100 );
		flAmount = flAmount / 100;
		
		strAmount = new String( flAmount );
		if( strAmount.indexOf( "." ) < 0 ) {
			strAmount += ".00";
		}
		
		if( strAmount.indexOf( "." ) == ( strAmount.length - 2 ) ) {
			strAmount += "0";
		}
		
		strAmount = strMinus + strAmount;
	}
	catch( e ) {
		HandleError( "FormatCurrency", e, M_strGFileName );
	}
	return strAmount;
}


/* Uses regex to trim whitespace */
function TrimWhitespace( strInput )
{
  var strReturn;
	
	try {
		strReturn =  strInput.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
	catch( e ) {
		HandleError( "TrimWhitespace", e, M_strGFileName );
	}
	
	return strReturn;
}

/* Positions an object. */
function SetObjectPosition( layer, intX, intY ) {
	try {
		
		var objLayer = GetObject( layer );
		
		if( objLayer != null ) {
			strX = String( intX );
			strY = String( intY );
			
			objLayer.style.top = intY + ( strY.indexOf("px") == -1 ? "px" : "" );
			objLayer.style.left = intX + ( strX.indexOf("px") == -1 ? "px" : "" );
		}
	}
	catch( e ) {
		HandleError( "SetObjectPosition" + e, M_strGFileName );
	}
}


/* Helper function to return baseline x coordinate parsed as int. */
function GetBasePositionX() {
	var objPos;
	try {
		objBase = GetBasePosition();
	}
	catch( e ) {
		HandleError( "GetBasePositionX" + e, M_strGFileName );
	}
	return parseInt( objBase.x );
}


/* Helper function to return baseline y coordinate parsed as int. */
function GetBasePositionY() {
	var objPos;
	try {
		objBase = GetBasePosition();
	}
	catch( e ) {
		HandleError( "GetBasePositionY" + e, M_strGFileName );
	}
	return parseInt( objBase.y );
}


/* For elements that we position absolutely, this function provides us the X and Y coordinate of the item
	that we use as our baseline for the topmost, leftmost item.  Presently its <div id="wrapper">*/
function GetBasePosition() {
	var objPos;
	
	try {
		objBase = document.getElementById( "global" );
		objPos = GetObjectPosition( objBase );
	}
	catch( e ) {
		HandleError( "GetBasePosition" + e, M_strGFileName );
	}
	return objPos;
}

/* Checks to see if we have an object or an object name.  If its a name, we get the object. */
function GetObject( layer ) {
		try {
			return ( typeof layer == "object" ? layer : document.getElementById( layer ) );
		}
		catch( e ) {
				HandleError( "GetObject", e, M_strGFileName );
		}
}

/* Changes an objects visibility to visible or hidden based on boolean. */
function ShowObject( layer, bIsVisible ) {
	try {
		var objLayer = GetObject( layer );
		
		if( objLayer != null ) {
			objLayer.style.visibility = ( bIsVisible ? "visible" : "hidden" );
		}
	}
	catch( e ) {
		HandleError( "ShowLayer", e, M_strGFileName );
	}
}

/* This function runs all the time - as a user mouses across the window.  We use it for lining up the options box with the holster
and potentially other usese in the future.  It sets global variables that let us access the x and y coordicates from our scripts. */
function GetMousePosition( e ) {
		
		try {
		if( window == null) alert('null');
		
		if (!e) var e = window.event;
		
		if ( e.pageX || e.pageY ) {
			M_iMouseX = e.pageX;
			M_iMouseY = e.pageY;
		}
		
		else if ( e.clientX || e.clientY ) {
			M_iMouseX = e.clientX + document.body.scrollLeft;
			M_iMouseY = e.clientY + GetScrollPositionY();
		}
		
	}
	catch( er ) {
		// This thing tweaks in IE when the page loads - swallow the error
		//HandleError( "GetMousePosition", er, M_strGFileName );
	}
}

/* Wrapper for javascript time out method. */
function SetTimeout( strCodeToRun, flTimeInSeconds ) {
	try {
		var flLimit = parseFloat( flTimeInSeconds ) * 1000;
		setTimeout( strCodeToRun, flLimit ); 
	}
	catch( e ) {
		HandleError( "SetTimeout", e, M_strGFileName );
	}
}

/* Gets the position(x,y) of an object in the window.  Makes adjustments for browsers.  Returns values as obj.x and obj.y */
function GetObjectPosition( target ) {
	
	var x = 0;
	var y = 0;
	var tempObj = new Object();
	try {
		var obj = GetObject( target );
	
		if( obj != null ) {
			while ( obj.offsetParent != null ) {
				x += obj.offsetLeft;
				y += obj.offsetTop;
				obj = obj.offsetParent;
			}
			
			x += obj.offsetLeft;
			y += obj.offsetTop;
		}
		
		tempObj.x = parseInt( x );
		tempObj.y = parseInt( y );
	}
	catch( e ) {
		HandleError( "GetObjectPosition", e, M_strGFileName );
	}
	return tempObj;
}

/* Gets broswer size.*/
function GetBrowserSize() {
  var intWidth, intHeight;
	var objReturn = new Object();
	
	try {
		intWidth = 0;
		intHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			intWidth = window.innerWidth;
			intHeight = window.innerHeight;
		}
		else if( document.documentElement &&
				( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			intWidth = document.documentElement.clientWidth;
			intHeight = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			intWidth = document.body.clientWidth;
			intHeight = document.body.clientHeight;
		}
		else {}
		
		objReturn.x = intWidth;
		objReturn.y = intHeight;
	}
	catch( e ) {
		HandleError( "GetBrowserSize", e, M_strGFileName );
	}
	return objReturn;	
}


/* Helper class for traversing nodes.  Originally written for parsing xml but can be used for html as well.*/
function XmlHelper( xml ) {
		var objXml = xml;
		
		// Gets attribute
		this.getAttribute = function( element, strAttName ) {
			var objElement;
			objElement = GetElementObj( element );
			
			return objElement.getAttribute( strAttName );
		}
		
		// Gets the text value of an element node
		this.getElementValue = function( element ) {
			var strValue, objElement;
			objElement = GetElementObj( element );
			
			strValue = "";
		
			if( objElement != null ) {
				strValue = objElement.firstChild.nodeValue;
			}
			
			return strValue;
		}
		
		// Gets a pointer to an element object
		this.getElement = GetElement;
		function GetElement( strElementName ) {
			return objXml.getElementsByTagName( strElementName )[0];
		}
		
		// Gets a collection of xml elements
		this.getElementSet = function( strElementName ) {
			return objXml.getElementsByTagName( strElementName );
		}
		
		/* Gets element type
			Element Node: 					1
			Attribute Node: 				2
			Text Node: 							3
			Comment Node: 					8
			Document Node: 					9
			Document Fragment Node: 11
			*/
		this.getElementType = function( element ) {
			var objElement = GetElementObj( element );
			
			return objElement.nodeType;
		}
		
		// Gets pointer to element object
		function GetElementObj( element ) {
			return ( typeof element == "object" ? element : GetElement( element ) );
		}
		
		// Is it an element node?
		function IsElementNode( element ) {
			return ( this.getElementType( element )  == 1 );
		}
		
		// Gets the true number of child nodes of type element
		function GetElementChildCount( xmlElement ) {
			var iCount, i;
			iCount = 0;
			
			if( xmlElement != null ) {
				for(i=0; i < xmlElement.childNodes.length; i++) {
					
					// Mozilla counts blank space as a child node.  Check for non-text nodes, only
					if( IsElementNode( xmlElement.childNodes[i]) ) {
						iCount++;
					}
				} // End Loop
			} // End if not null

			return iCount;
		}
		
		// Gets the name of the element
		function GetElementName( element ) {
			return ( typeof element == "object" ? element.nodeName : element );
		}
		
		// Gets element child count
		this.getChildCount = function( element ) {
			var objElement = GetElementObj( element );
			
			return GetElementChildCount( objElement );
		}
	} // End XmlHelper Object
	

/**********************************************************************
To use this in code, simply type: BrowserInfo.isIE() or BrowserInfo.hdnShowPFW() etc...
Code is optimized to only fetch the value one time.
************************************************************************/
function BrowserDetect2() {
	var _strFrameName 		= "ifrHolsterInfo";
	var _objIE 				= new BrowserProperty( "hdnIsIE", _strFrameName );
	var _objFF 				= new BrowserProperty( "hdnIsFF", _strFrameName );
	var _objSafari 			= new BrowserProperty( "hdnIsSafari", _strFrameName );
	var _objShowPFW 		= new BrowserProperty( "hdnShowPFW", _strFrameName );
	
	this.isIE = function() {
		return _objIE.isOfType();
	}
	
	this.isFF = function() {
		return _objFF.isOfType();
	}
	
	this.isSafari = function() {
		return _objSafari.isOfType();
	}
	
	this.showPFW = function() {
		return _objShowPFW.isOfType();
	}
	
}

/* BrowserProperty class*/
function BrowserProperty( strField, strFrame ) {
	var _bIsSet 				= false;
	var _bIsType 				= false;
	var _strFieldName 	= strField;
	var _strFrameName 	= strFrame;
	
	this.isOfType = function() {
		var bReturn = false;

		/*if( _bIsSet ) {
			bReturn = _bIsType;
		}
		else {*/
			_bIsType = this.getHiddenBrowserVal();
			return _bIsType;
		//}

		return bReturn;
	}
	
	this.getHiddenBrowserVal = function() {
		var bReturnVal 			= false;
		var ifrHolsterInfo 	= window.frames[_strFrameName];

		if ( ifrHolsterInfo != null ) {
			if( ifrHolsterInfo.document.getElementById( _strFieldName ) ) {
				bReturnVal = Boolean( parseInt( ifrHolsterInfo.document.getElementById( _strFieldName ).value ) );
				_bIsSet = true;
			}
			else {
				bReturnVal = false;
			}
		}
		return bReturnVal;
	}
}

