
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function closeWindow() {
        top.close();
        return false;
}
var modifyWindow;
function OpenWindow(url,width,height,scrollbars,windowname)
{
	var w = width;
	var h = height;
	var s = scrollbars;
	var x = 100;
	var y = 150;
	if (document.all)
	{
		var xMax = screen.width, yMax = screen.height;
		x = ((xMax/2) - (w/2));
		y = ((yMax/2) - (h/2));
	}
	else if (document.layers) 
	{
		var xMax = window.outerWidth, yMax = window.outerHeight;
		x = ((xMax/2) - (w/2));
		y = ((yMax/2) - (h/2));
	}
	
	options = "screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x + ",directories=0,toolbar=0,status=0,menubar=0,scrollbars="+ s +",resizable=1,width=" + w +",height=" + h;
	modifyWindow = window.open(url,windowname,options);
	if (modifyWindow.opener == null) 
		modifyWindow.opener = self;
	modifyWindow.focus();
}
// Very basic.. changes the colors.. two variables passed.
// tr and the color to change it to..
function onColor(lay, thisColor)
{
	lay.style.backgroundColor=thisColor;
}

function offColor(lay, thisColor)
{
	if (thisColor == "cccc99")
	{
		lay.style.backgroundColor = 'DBE4F8';
	}
	else
	{
	lay.style.backgroundColor=thisColor;
	}
}
function changeClass(lay, newClass)
{
	lay.className=newClass;
}

function callFormValidation(form) {
 if (validateForm(form,0,0,0,0)){
  form.submit();
 }
}		

// Parts of Code By:  Gregor (legreg@legreg.de) 
// Modified by Umer Farooq (umer@octadyne.com)
// (c) Octadyne System Inc.
// You can use this code as long as the above notices stay in place.
angel = (navigator.appName == "Netscape");
devel = (navigator.appName == "Microsoft Internet Explorer");
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay) {
if (ie4) {
          document.all[lay].style.visibility = "hidden"; 
          document.all[lay].style.zIndex = 0;
		  }
else if (ns4) {document.layers[lay].visibility = "hide";
          }
else if (ns6) {
//document.getElementById([lay]).style.visibility = "hidden";
// The above listed code seems to work as long as the layer is visible from the start..
// but if the layer is hidden from the start it doesn't work..
// So we get all the div tags.. and then we select the div tag we are working on
// and go from there. Draw back is we might run into problems with the layer being 
// set in the span tag. But since SPAN is not to happy in netscape.. we will stay away from it.
// if u use span then you can fix that by.. checking if the divTags[lay] is defined.. 
// if it is not then u would work with the span..
 divTags = document.getElementsByTagName("div");
 divTags[lay].style.visibility = "hidden";
}
}
function showlayer(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {
//document.getElementById([lay]).style.visibility = "visible";
 divTags = document.getElementsByTagName("div");
 divTags[lay].style.visibility = "visible";
 }
}

   function writeEmailAddress(name,domain) {
	   Address=(name+ '@' +domain)
	   document.write('<a href="mailto:' + Address + '">' + Address + '</a>')
   }
   
   function goToLocation(url)
   {
   		document.location.href = url;
   }
   
function sendToLocation(location)
{
	document.location.href= location;
}	


var onBodyLoads = new Array();
function bodyOnLoad() {
     for ( var i = 0 ; i < onBodyLoads.length ; i++ )
        onBodyLoads[i]();
  }
  
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}  


function checkAllBoxes(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAllBoxes(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}


// this is to attach events... note this is likly covered in other libs
// and should be removed on the next system wide update. but since the code is
// so large it may stick around forever... 
function _ajAddEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function _ajWriteFlash(url,width,height,wmode,name)
{
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'");
	document.write(" width='" + width + "' height='" + height + "' id='" + name + "'");
	document.write(">");
	document.write("<param name='wmode' value='" + wmode + "'>");
	document.write(" <param name='src' value='" + url + "'>");
	document.write(" <embed pluginspage='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash'");
	document.write(" NAME='" + name + "' width='" + width + "' height='" + height + "' wmode='" + wmode + "'");
	document.write(" src='" + url + "'");
	document.write(" />");
	document.write("</object>");

}
function _ajBuildFlashHTML(url,width,height,wmode,name)
{
	var flashHtml = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'";
	flashHtml +=" width='" + width + "' height='" + height + "' id='" + name + "'";
	flashHtml +=">";
	flashHtml +="<param name='wmode' value='" + wmode + "'>";
	flashHtml +=" <param name='src' value='" + url + "'>";
	flashHtml +=" <embed pluginspage='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash'";
	flashHtml +=" NAME='" + name + "' width='" + width + "' height='" + height + "' wmode='" + wmode + "'";
	flashHtml +=" src='" + url + "'";
	flashHtml +=" />";
	flashHtml +="</object>";
	return flashHtml;
}

function _ajAttachOnloadEvent(handler)
{
	if (typeof window.addEventListener != 'undefined')
		window.addEventListener('load', handler, false);
	else if (typeof document.addEventListener != 'undefined')
		document.addEventListener('load', handler, false);
	else if (typeof window.attachEvent != 'undefined')
		window.attachEvent('onload', handler);
}

function _ajStatRecordClick (altText,imgSrc)
{
	var currentTime=new Date();
	var IsOnHomePage=1;
	var strTrackerURL="/cms.cfm?ajExtCall=ajlib&altText=" + altText + "&IsOnHomePage=" + IsOnHomePage + "&imgsrc=" + imgSrc + "&" + currentTime.getTime();
	if(document.images) {
		var objImg=new Image();
		objImg.src=strTrackerURL;
	}
	return true;
}

// I'm a helper function and require jQuery
function _ajWishCompareAjax(inventoryId,fuseaction,action,updateElement){
	jQuery.ajax({
				type: "post",
				url: "/inventory/ajax.cfm",
				data: {type:"inventory", inventoryId: inventoryId, fuseaction: 'inventory.' + fuseaction, action: action},
				success: function(msg)
				{
					jQuery(updateElement).parent().effect("highlight", {}, 3000);
					jQuery(updateElement).html( "(" + jQuery.trim(msg) + ")");
					

				}
			});
}
// From http://calisza.wordpress.com/2008/11/03/javascript-jquery-bookmark-script/
jQuery(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if (jQuery("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			jQuery("a.jqbookmark").attr("rel","sidebar");
		}
	}

	jQuery("a.jqbookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = document.location;
		var title = document.title;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}

	});
});
