// MVRstandard.js  
// Standard Javascript functions for MetaVR pages  
// Copyright MetaVR, Inc., 2001, 2002  
  
var platform = navigator.appVersion;  
browserName = navigator.appName;  
browserVer = parseInt(navigator.appVersion);  
  
//determine browser  
    if (browserName == "Netscape" && browserVer >= 3)  
        version = "n3";  
    else if (browserName == "Netscape" && browserVer < 3)  
        version = "n2";  
    else if (browserName == "Microsoft Internet Explorer" && browserVer >= 2)  
        version = "e3";  
//end of determine browser  
  
//preload images  
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];  
			}  
	}  
}  
  
// uncomment the following line and edit as needed to preload images  
//MM_preloadImages('image1.gif','image2.gif','image3.gif','image4.gif');  
  
//end image preload  
  
function MM_reloadPage(init) {  //reloads the window if Nav4 resized  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {  
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}  
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();  
}  
MM_reloadPage(true);  
  
  
function swapImage(imgObj, imgsrc1, imgsrc2)  
{  
//	alert("swapping source for: " + imgObj);  
//	alert("swapping: " + imgObj.src);  
	if ( imgObj.src.indexOf(imgsrc1) != -1 )  
	{  
		imgObj.src = imgsrc2;  
//		alert("swapping to: " + imgsrc2);  
	}  
	else  
	{  
		imgObj.src = imgsrc1;  
//		alert("swapping to: " + imgsrc1);  
	}  
}  

function cycleImages()  
{
   args = cycleImages.arguments;
   imgObj = args[0];
   limit = args.length;

// alert("swapping source for: |" + imgObj + "| name: "+imgObj.name +" limit="+limit);  

// for( i=1; i<limit; i++) {"image "+i+": "+alert(args[i]); }

   if (limit < 3) return;  // only 1 image nothing to cycle through

   if ( imgObj.displayIndex == null) imgObj.displayIndex = 1;

  	ndx = imgObj.displayIndex;

// alert("swapping: " + imgObj.src + " Index: " + ndx);  

   if ( ndx == limit - 1)
   {
      // next image is the 1st in the list
      ndx = 1;
   }
   else
   {
      ndx++;
   }
	imgObj.src = args[ndx];
   imgObj.displayIndex = ndx;
//	alert("swapping to: " + args[ndx] + " ndx="+ndx);  
}  
  
var win = null;  
  
function imageWin(loc, target)  
{  
    var exitVal = true;  
  
    // This one opens the window  
    win = window.open('', target, 'width=655,height=495,resizable=yes,scrollbars=yes');  
    if (win != null)  
    {  
        win.location.href = loc;  
		win.focus();  
        exitVal = false;  
    }  
    return exitVal;  
}  
  
 function imageWinSizeable(loc, target, width, height)  
{  
    var exitVal = true;  
  
    // This one opens the window  
    win = window.open('', target, 'width='+width+',height='+height+',resizable=yes,scrollbars=yes');  
    if (win != null)  
    {  
        win.location.href = loc;  
                win.focus();  
        exitVal = false;  
    }  
    return exitVal;  
}   
  
function popUpWin(loc)  
{  
    // This one opens the window  
    win = window.open('', 'popUpWin', 'width=400,height=300,scrollbars=1,resizable=yes');  
    if (win != null)  
    {  
        if (win.opener == null)  
        {  
            win.opener = self;  
        }  
        win.location.href = loc;  
				win.focus();  
    }  
}  
  
//not needed   
//function frameCheck()  
//{  
//	if ( parseInt(navigator.appVersion) < 3 )  
//		return;	// we can't do frames anyway so don't bother!  
//  
//	if ( window.parent == self )   
//	{  
		// we are not in a frame!  
//		oldhref = document.location.href;  
        //alert('oldhref='+oldhref);  
//		document.location.href = '/reFrameIndex.html?'+oldhref;  
//	}  
//}  
  
function formatPrice(price)  
{  
    strPrice = new String(price);  
    if ( strPrice.indexOf('.') == -1 )  
    {  
        strPrice = strPrice + ".00";  
    }  
    ndx = strPrice.indexOf('.');  
    if ( ndx > 3 )  
    {  
        // need commas  
        for (i=ndx-3; i>0; i-=3)  
        {  
//alert("i="+i  
//+"\n strPrice.substring(0,i-1)="+strPrice.substring(0,i)  
//+"\n strPrice.substring(i)="+strPrice.substring(i));  
            tmp = strPrice.substring(0,i) + ',' + strPrice.substring(i);  
            strPrice=tmp;  
        }  
    }  
    if ( strPrice.length - strPrice.indexOf('.') < 3 )  
    {  
        // add trailing 0  
        strPrice = strPrice + "0";  
        if ( strPrice.length - strPrice.indexOf('.') < 3 )  
        {  
            // add another trailing 0  
            strPrice = strPrice + "0";  
        }  
    }  
    return strPrice;  
}  
