//to bustAmove outa someone else's frameSet
/* if (top.frames.length!=0) {
    if (window.location.href.replace)
        top.location.replace(self.location.href);
    else
        top.location.href=self.document.href;
}
*/

function hideLayer(whichLayer)
{
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "hidden";
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "hidden";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "hidden";
	}
}

function showLayer(whichLayer)
{
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "visible";
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "visible";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "visible";
	}
}

//=========================================================
//write cookie without a date
function cookieSniffer(){ 
	if (document.cookie.length < 1)
	{
		document.write('<!-- *** FUNCTION COOKIESNIFFER() START (/js/site.js) *** --> <table border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="5" align="left" valign="top" bgcolor="009900"><img src="/images/frame/crn-white-tl.gif" width="5" height="5" alt=""></td> <td bgcolor="009900"><img src="/images/clear.gif" width="20" height="2" alt=""></td> <td bgcolor="009900" width="5" align="right" valign="top"><img src="/images/frame/crn-white-tr.gif" width="5" height="5" alt=""></td> </tr> <tr> 	<td bgcolor="009900" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> <td> <table class="status" width="100%" border="0" cellspacing="0" cellpadding="5">		<tr>  <td valign="top"><b><font color="009900" size="+1" face="Arial, Helvetica, sans-serif">Cookies Not Enabled</font></b> <table width="100%" border="0" cellspacing="0" cellpadding="0">  <tr> <td bgcolor="009900"><img src="/images/clear.gif" width="5" height="2"></td> </tr> </table> <ul> <li>You either have Cookies turned off or your browser does not support Cookies.</li> <li>A Cookie is: A very small text file placed on your hard drive by a Web Page server. <br> It is essentially your identification card, and cannot be executed as code or deliver viruses. <br> It is uniquely yours and can only be read by the server that gave it to you.</li> <li>PartsLogistics.com requires Cookies to validate your input and to ensure<br>				that your purchases are accurately processed. </li> <li>If you are using a browser less than version 5.0, we recommend 				you upgrade to the latest version: <ul>  <li><a href="http://www.microsoft.com/mac/products/ie/" target="_blank">Internet					Explorer (IE) for MacOS</a></li> <li><a href="http://www.microsoft.com/windows/ie/" target="_blank">Internet Explorer (IE) for Windows</a></li> <li><a href="http://wp.netscape.com/computing/download/" target="_blank">Netscape 					for MacOS or Windows</a></li> </ul> </li>   <li>For more information on the status of Cookies for your browser please select the appropriate link: <ul><li>' + '<a href=' + "'" + 'javascript:void(openWindow(' + '"faq","IE","600","700"));' + "'>" + 'If you are using Internet Explorer.</a></li><li><a href="javascript:void(openWindow(\'faq\',\'MZ\',\'600\',\'735\'));">If you are using Mozilla.</a></li><li><a href="javascript:void(openWindow(\'faq\',\'NS7\',\'600\',\'730\'));">If you are using Netscape, newer versions.</a></li><li><a href="javascript:void(openWindow(\'faq\',\'NS475\',\'350\',\'640\'));">If you are using Netscape, older versions.</a></li><li><a href="/help.php?sub=faq">or visit our FAQ page</a>.</li></ul></ul>   <ul>  <li>If you have any questions about this process, please contact 				the Technical Support team <ul> <li> using our <a href="/contactus.php">Contact Us</a> page,</li> <!-- {livePerson}-error-javascript eeb --> <li>or call toll free at 1-877-909-9111<!-- {contact_tollfree} -->.</li> </ul>     </td> </tr> </table> </td>	<td bgcolor="009900" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> </tr> <tr> <td bgcolor="009900" width="5" align="left" valign="bottom"><img src="/images/frame/crn-white-bl.gif" width="5" height="5" alt=""></td> <td bgcolor="009900"><img src="/images/clear.gif" width="20" height="2" alt=""></td>	<td bgcolor="009900" width="5" align="right" valign="bottom"><img src="/images/frame/crn-white-br.gif" width="5" height="5" alt=""></td>  </tr> </table> <br> <!-- *** FUNCTION COOKIESNIFFER() END (/js/site.js) *** -->')
	}
}//end function cookieSniffer()
//=========================================================

// displayStatus
// Displays the passed message in the status bar.
// ==================================================
function displayStatus(message) {
	window.status=message;
	return true;
}

// printPage
// Calls window.print to print the current page if the browser supports this action.
// If unsupported, displays an error message and instructs the user to print it their own damn self.
// ==================================================
function printPage() {
	if(window.print) {
  		window.print();
	} else {
		alert("Your browser does not support button-click printing.\nTo print this page, please go to the File menu and select the Print command, or use the keyboard shortcut for your system (Control + P for Windows, Command + P for Mac OS).");
	}
}

// openWindow
// Opens a new window with the specified parameters.
// ==================================================
var popupwindow;
function openWindow(type, anchorName, heightU, widthU, hrefU, targetU, menubarU, toolbarU, locationU, directoriesU, statusU, scrollbarsU, resizableU, leftU, topU) {
	// Defaults
	var href = '/popup.php/';
	var target = 'popup';
	var features;
	var menubar = 'no';			// File, Edit, etc.
	var toolbar = 'no';			// Back, Next, etc.
	var location = 'no';		// Location bar.
	var directories = 'no';		// Bookmark bar.
	var status = 'yes';			// Status bar at bottom of window.
	var scrollbars = 'yes';
	var resizable = 'yes';
	var left = 100;				// Distance from
	var top = 100;				// edge of screen.
	var width = 500;
	var height = 400;
		
	if (heightU) height = heightU;
	if (widthU) width = widthU;
	if (hrefU) href = hrefU;
	if (targetU) target = targetU;
	

	switch (type) {
		// Preview of Reports
		case "drms":
			href = href + type + '+' + anchorName;
			break;
	
		case "reports":
			href = href + type + '+' + anchorName;
			if (widthU) {
				width = widthU;
			}
			else {
				width = 750;
			}
			if (heightU) height = heightU;
			else height = 500;
			if (anchorName == 'compReportSummary'){target = '_blank'}
			break;

		// Preview of an RFQ
		case "autorfq":
			href = href + type + '+' + anchorName;
			width = 750;
			if (heightU) height = heightU;
			else height = 600;
			break;

		// Legend
		case "legend":
			href = href + type + '+' + anchorName;
			break;
			
		// Lost Password
		case "lost_password":
			href = href + type + '+' + anchorName;
			break;

		// Contextual Help Icons
		case "in-depth":
			href = href + type + '+' + anchorName;
			break;

		// Glossary of terms
		case "glossary":
			href = href + type + '+' + anchorName;
			if (heightU) height = heightU;
			break;

		// Glossary of terms
		case "faq":
			href = href + type + '+' + anchorName;
			if (heightU) height = heightU;
			else height = 500;
			break;

		// Prepare proccessing parameters for custom window.
		case "custom":
			var userFeatures = true;
			break;

		case "dashboard":
			href = href + type + '+' + anchorName;
			
         break;

		case "services":
			href = href + type + '+' + anchorName;
			break;

		case "profile":
			href = href + type + '+' + anchorName;
			break;

		case "category":
			href = href + type + '+' + anchorName;
			break;

		default:
			break;
	}

	// If the user has not provided features, use the defaults and whatever per-type changes are made.
	// Else, use the features provided by the user.
	if (!userFeatures) {
		features = 'menubar='+menubar+',toolbar='+toolbar+',location='+location;
		features += ',directories='+directories+',status='+status;
		features += ',scrollbars='+scrollbars+',resizable='+resizable;
		features += ',left='+left+',top='+top+',width='+width+',height='+height;

	} else {
		features = 'menubar='+menubarU+',toolbar='+toolbarU+',location='+locationU;
		features += ',directories='+directoriesU+',status='+statusU;
		features += ',scrollbars='+scrollbarsU+',resizable='+resizableU;
		features += ',left='+leftU+',top='+topU+',width='+widthU+',height='+heightU;
	}

	// Close the window if it's open; may need to change visibility of bars, window size, etc.
	if (popupwindow && !popupwindow.closed) popupwindow.close();
	if (type)
	{ popupwindow=window.open(href,target,features);}
//document.write(href);
}

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 check_flash(skipCheck)
{
    var MM_FlashCanPlay = false;
    if (skipCheck != 1) {
        var MM_contentVersion = 6;
        var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
        if ( plugin ) {
            var words = navigator.plugins["Shockwave Flash"].description.split(" ");
            for (var i = 0; i < words.length; ++i)
            {
                if (isNaN(parseInt(words[i])))
                    continue;
                  var MM_PluginVersion = words[i];
            }
            MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
        }
		if (navigator.appName == "Microsoft Internet Explorer") {
			if ((navigator.appVersion.indexOf("3.1") == -1) || (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >=4)){ 
				MM_FlashCanPlay = true;
			}
        }
    }
    else {
        MM_FlashCanPlay = true;
    }
    return MM_FlashCanPlay;
}

function correctPNG() {
    for(var i=0; i<document.images.length; i++) {
        var img = document.images[i]
        var imgName = img.src.toUpperCase()
        if (imgName.substring(imgName.length-15, imgName.length) != "ALTMENULINE.PNG") {
            if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i-1
            }
        }
    }
}
