// JavaScript Document

window.onload=function(){
 initMyPicks();
 MM_preloadImages('/lib/edressme/82-my-picks-div.gif');
}



// order staus  and OMX window
function getOmxURL() {
var url='http://orderstatus.ordermotion.com/index.asp?OrderNumber='+omxStatus.OrderNumber.value+'&ZIP='+omxStatus.ZIP.value+'&Command=Lookup&MerchantID=g0m6-t1p5-e1f1-f8z7';
document.getElementById('OMX').innerHTML ="<div id='closeIF'><a href='#' onClick='closeFrame()'><img src='/lib/edressme/closelabel.gif'></a></div>     <iframe src='"+ url+"' width='700' height='600'  frameborder='0'  scrolling='yes' resizeable='yes' align='top'></iframe>"
}
function openUPS () {
document.getElementById('OMX').innerHTML ="<div id='closeIF'><a href='#' onClick='closeFrame()'><img src='/lib/edressme/closelabel.gif'></a></div><iframe src='return-label-div.html' width='700' height='600'  frameborder='0'  scrolling='yes' resizeable='yes' align='top'></iframe>"
}


function closeFrame() {
document.getElementById('OMX').innerHTML='';
}


//hide images for zoom
function image1(){
document.getElementById("obj1").style.display="inline";
document.getElementById("obj2").style.display="none";
document.getElementById("obj3").style.display="none";
document.getElementById("obj4").style.display="none";
}

function image2(){
document.getElementById("obj1").style.display="none";
document.getElementById("obj2").style.display="inline";
document.getElementById("obj3").style.display="none";
document.getElementById("obj4").style.display="none";
}

function image3(){
document.getElementById("obj1").style.display="none";
document.getElementById("obj2").style.display="none";
document.getElementById("obj3").style.display="inline";
document.getElementById("obj4").style.display="none";
}

function image4(){
document.getElementById("obj1").style.display="none";
document.getElementById("obj2").style.display="none";
document.getElementById("obj3").style.display="none";
document.getElementById("obj4").style.display="inline";
}



//set filters and myPicks copyright edressme.com 2009 all rights reserved
function showAll(){
  document.getElementById("contentsTable").style.display='block';
document.getElementById("filterTable").style.display='none';

}

function setFilter(filter){
var i,segs,contents;
var n=new Array();

switch (filter){
 case "white":
   n=white.split(' ');
   break;
 case "red":
   n=red.split(' ');
   break;
 case "pink":
   n=pink.split(' ');
   break;
 case "yellow":
   n=yellow.split(' ');
   break;
 case "green":
   n=green.split(' ');
   break;
 case "blue":
   n=blue.split(' ');
   break;
 case "black":
   n=black.split(' ');
   break;
 case "purple":
   n=purple.split(' ');
   break;
 case "brown":
   n=brown.split(' ');
   break;

  case "XS":
   n=XS.split(' ');
   break;
  case "S":
   n=S.split(' ');
   break;
  case "M":
   n=M.split(' ');
   break;
 case "L":
   n=L.split(' ');
   break;
 case "XL":
   n=XL.split(' ');
   break;
   
 case "u1":
   n=u1.split(' ');
   break;
 case "u2":
   n=u2.split(' ');
   break;
 case "u3":
   n=u3.split(' ');
   break;
 case "o3":
   n=o3.split(' ');
   break;
}

segs=Math.ceil((n.length-2)/5);

//alert ( segs );

contents='<table border="0" cellpadding="0" cellspacing="0">';

for( i=0;i< segs;i++ ) {
    contents=contents + '<tr>';

    for( j=(i*5)+1;j<(i*5)+6 && j< (n.length-1) ;j++ ){

      contents=contents + '<td class="img-table">'+ document.getElementById("img-"+n[j] ).innerHTML + '</td>';
        }

    contents=contents + '</tr>';

    for( k=(i*5)+1;k<(i*5)+6 && k <(n.length-1);k++ ){
        contents=contents + '<td class="icon-table2">'+ document.getElementById("cap-"+ n[k] ).innerHTML + '</td>';
        }

     contents=contents + '</tr>';

   }

contents=contents + '</table>';



document.getElementById("contentsTable").style.display='none';
document.getElementById("filterTable").style.display='block';

document.getElementById("filterTable").innerHTML=contents;


}


// myPicks
function initMyPicks() {
	var MyPicks;
		MyPicks=getCookie('myPicks');
	//myPicks='2069_366503144,black-dress-118sq|2065_153448422,4067i7';

//alert('myPicks cookie: '+ myPicks);
		if (MyPicks!=null && MyPicks!="") {
			displayPicks(MyPicks);
		}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function addPick(image,id){
	//remove http from image  for condensed cookie
	imageIndex=image.indexOf("yhst-32854445011678_");
	image=image.substr(imageIndex + 20);
	var MyPicks;
	MyPicks=getCookie('myPicks');
	//myPicks='2069_366503144,black-dress-118sq|2065_153448422,4067i7';
	//myPicks='2069_366503144,black-dress-118sq';
    ck_value=MyPicks;
	if (MyPicks!=null && MyPicks!="") {
		// add new pick to beginning of myPicks value first check if id is already used
		if (checkImage(image,MyPicks) == null){
			//if image not found add to begining of value
			ck_value=image+','+id.toLowerCase() +'|'+MyPicks;

		}
		setCookie('myPicks',ck_value,365);

  	}
	else{
		ck_value=image+','+id.toLowerCase() ;
		setCookie('myPicks',ck_value,365);
	}
displayPicks(ck_value);	
}

function checkImage(image,current_ck){
	var split_ck;
	split_ck=current_ck.split("|");
	var i;
	for(i=0;i<split_ck.length;i++) {
   		Pick=split_ck[i].split(",");
		if(image == Pick[0]){return 1;}
	}
	return null;
}

function removePick(id) {
		var MyPicks;
		MyPicks=getCookie('myPicks');
		//myPicks='2069_366503144,black-dress-118sq|2065_153448422,4067i7';

		allPicks=MyPicks.split("|");
		var i,j;
		var ck_value=new Array();
	var allImages="";
	for(i=0,j=0;i<allPicks.length;i++) {
   		Pick=allPicks[i].split(",");
		if( Pick[1] == id ) {
			//ck_value[i]='';
		}
		else {
			ck_value[j]=Pick[0]+','+Pick[1];
			j++;
		}
	}
	if( ck_value[0] == null) {
	setCookie('myPicks','',365);
	document.getElementById('myPicks').innerHTML='';

	}
	else{
	MyPicks=ck_value.join("|");
	setCookie('myPicks',MyPicks,365);
	displayPicks(MyPicks);
	}
	
}


function displayPicks(myPicks){
	allPicks=myPicks.split("|");
	var i;
	var allImages="";
	for(i=0;i<allPicks.length;i++) {
   		Pick=allPicks[i].split(",");
   		Anchor=Pick[1];
		currentImage='<table style="float:left" bgcolor="#FFFFFF"><tr><td ><a href="'+Anchor+'.html"><img src="http://ep.yimg.com/ca/I/yhst-32854445011678_'+Pick[0]+'" width=120 height=240 border=0 hspace=0 vspace=0 class="borderWide"></a></td></tr><tr><td align="center"><a href="#" onClick="removePick(\''+Anchor+'\')">remove pick</a></td></tr></table>';
		//if( i>1 && (i% 4) == 0 && i<allPicks.length ) { currentImage = currentImage + '<br>';} 
		allImages=allImages+currentImage;
	}
	
	document.getElementById('myPicks').innerHTML=allImages;
	//document.getElementById('myPicks').innerHTML='<table><tr><td bgcolor="#FFFFFF"><span class="sale">My Picks</span></td></tr><tr><td>'+allImages+'</td></tr></table>';

}


// end of myPicks  


// video functions
function showVideo(videoClip){
document.getElementById('video').innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="635" height="370"> <param name="movie" value="http://www.edressme.com/lib/edressme/flashplayer04.swf?vid='+videoClip+'" /> <param name="quality" value="high" /><param name="BGCOLOR" value="#FFFFFF" /><embed src="http://www.edressme.com/lib/edressme/flashplayer04.swf?vid='+videoClip+'" width="635" height="370" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#FFFFFF"></embed></object><center><a href=# onClick="closeVideo()">CLOSE WINDOW</a><br><br><br></center>';
}

function closeVideo(){
document.getElementById('video').innerHTML='';
}


//find my size functions
function showSize()
{
window.scrollTo(0,400);
document.getElementById("description").style.display="none";
document.getElementById("findSize").style.display="block";

}

function hideSize()
{
document.getElementById("description").style.display="block";
document.getElementById("findSize").style.display="none";

}


/*Rollover effect on different image script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

function changeimage(towhat,url){
if (document.images){
document.images.targetimage.src=towhat.src
gotolink=url
}
}
function warp(){
window.location=gotolink
}


var myimages=new Array()
var gotolink="#"

function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}


function Rcertify() 
{
popupWin = window.open('http://www.bbbonline.org/cks.asp?id=1040223859638182', 'Participant','location=yes,scrollbars=yes,width=450,height=300'); 
window.name = 'opener';
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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 Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
	this.version = "020320 [Menu; mm_menu.js]";
	this.type = "Menu";
	this.menuWidth = mw;
	this.menuItemHeight = mh;
	this.fontSize = fs;
	this.fontWeight = "plain";
	this.fontFamily = fnt;
	this.fontColor = fclr;
	this.fontColorHilite = fhclr;
	this.bgColor = "#555555";
	this.menuBorder = 1;
	this.menuBgOpaque=opq;
	this.menuItemBorder = 1;
	this.menuItemIndent = idt;
	this.menuItemBgColor = bg;
	this.menuItemVAlign = valgn;
	this.menuItemHAlign = halgn;
	this.menuItemPadding = pad;
	this.menuItemSpacing = space;
	this.menuLiteBgColor = "#ffffff";
	this.menuBorderBgColor = "#777777";
	this.menuHiliteBgColor = bgh;
	this.menuContainerBgColor = "#cccccc";
	this.childMenuIcon = "arrows.gif";
	this.submenuXOffset = sx;
	this.submenuYOffset = sy;
	this.submenuRelativeToItem = srel;
	this.vertical = vert;
	this.items = new Array();
	this.actions = new Array();
	this.childMenus = new Array();
	this.hideOnMouseOut = true;
	this.hideTimeout = to;
	this.addMenuItem = addMenuItem;
	this.writeMenus = writeMenus;
	this.MM_showMenu = MM_showMenu;
	this.onMenuItemOver = onMenuItemOver;
	this.onMenuItemAction = onMenuItemAction;
	this.hideMenu = hideMenu;
	this.hideChildMenu = hideChildMenu;
	if (!window.menus) window.menus = new Array();
	this.label = " " + label;
	window.menus[this.label] = this;
	window.menus[window.menus.length] = this;
	if (!window.activeMenus) window.activeMenus = new Array();
}

function addMenuItem(label, action) {
	this.items[this.items.length] = label;
	this.actions[this.actions.length] = action;
}

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function writeMenus(container) {
	if (window.triedToWriteMenus) return;
	var agt = navigator.userAgent.toLowerCase();
	window.mmIsOpera = agt.indexOf("opera") != -1;
	if (!container && document.layers) {
		window.delayWriteMenus = this.writeMenus;
		var timer = setTimeout('delayWriteMenus()', 500);
		container = new Layer(100);
		clearTimeout(timer);
	} else if (document.all || document.hasChildNodes || window.mmIsOpera) {
		document.writeln('<span id="menuContainer"></span>');
		container = FIND("menuContainer");
	}

	window.mmHideMenuTimer = null;
	if (!container) return;	
	window.triedToWriteMenus = true; 
	container.isContainer = true;
	container.menus = new Array();
	for (var i=0; i<window.menus.length; i++) 
		container.menus[i] = window.menus[i];
	window.menus.length = 0;
	var countMenus = 0;
	var countItems = 0;
	var top = 0;
	var content = '';
	var lrs = false;
	var theStat = "";
	var tsc = 0;
	if (document.layers) lrs = true;
	for (var i=0; i<container.menus.length; i++, countMenus++) {
		var menu = container.menus[i];
		if (menu.bgImageUp || !menu.menuBgOpaque) {
			menu.menuBorder = 0;
			menu.menuItemBorder = 0;
		}
		if (lrs) {
			var menuLayer = new Layer(100, container);
			var lite = new Layer(100, menuLayer);
			lite.top = menu.menuBorder;
			lite.left = menu.menuBorder;
			var body = new Layer(100, lite);
			body.top = menu.menuBorder;
			body.left = menu.menuBorder;
		} else {
			content += ''+
			'<div id="menuLayer'+ countMenus +'" style="position:absolute;z-index:1;left:10px;top:'+ (i * 100) +'px;visibility:hidden;color:' +  menu.menuBorderBgColor + ';">\n'+
			'  <div id="menuLite'+ countMenus +'" style="position:absolute;z-index:1;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;" onmouseout="mouseoutMenu();">\n'+
			'	 <div id="menuFg'+ countMenus +'" style="position:absolute;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;">\n'+
			'';
		}
		var x=i;
		for (var i=0; i<menu.items.length; i++) {
			var item = menu.items[i];
			var childMenu = false;
			var defaultHeight = menu.fontSize+2*menu.menuItemPadding;
			if (item.label) {
				item = item.label;
				childMenu = true;
			}
			menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
			var itemProps = '';
			if( menu.fontFamily != '' ) itemProps += 'font-family:' + menu.fontFamily +';';
			itemProps += 'font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + 'px;';
			if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
			if (document.all || window.mmIsOpera) 
				itemProps += 'font-size:' + menu.fontSize + 'px;" onmouseover="onMenuItemOver(null,this);" onclick="onMenuItemAction(null,this);';
			else if (!document.layers) {
				itemProps += 'font-size:' + menu.fontSize + 'px;';
			}
			var l;
			if (lrs) {
				var lw = menu.menuWidth;
				if( menu.menuItemHAlign == 'right' ) lw -= menu.menuItemPadding;
				l = new Layer(lw,body);
			}
			var itemLeft = 0;
			var itemTop = i*menu.menuItemHeight;
			if( !menu.vertical ) {
				itemLeft = i*menu.menuWidth;
				itemTop = 0;
			}
			var dTag = '<div id="menuItem'+ countItems +'" style="position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';
			var dClose = '</div>'
			if (menu.bgImageUp) dTag = '<div id="menuItem'+ countItems +'" style="background:url('+menu.bgImageUp+');position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';

			var left = 0, top = 0, right = 0, bottom = 0;
			left = 1 + menu.menuItemPadding + menu.menuItemIndent;
			right = left + menu.menuWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
			if( menu.menuItemVAlign == 'top' ) top = menu.menuItemPadding;
			if( menu.menuItemVAlign == 'bottom' ) top = menu.menuItemHeight-menu.fontSize-1-menu.menuItemPadding;
			if( menu.menuItemVAlign == 'middle' ) top = ((menu.menuItemHeight/2)-(menu.fontSize/2)-1);
			bottom = menu.menuItemHeight - 2*menu.menuItemPadding;
			var textProps = 'position:absolute;left:' + left + 'px;top:' + top + 'px;';
			if (lrs) {
				textProps +=itemProps + 'right:' + right + ';bottom:' + bottom + ';';
				dTag = "";
				dClose = "";
			}
			
			if(document.all && !window.mmIsOpera) {
				item = '<div align="' + menu.menuItemHAlign + '">' + item + '</div>';
			} else if (lrs) {
				item = '<div style="text-align:' + menu.menuItemHAlign + ';">' + item + '</div>';
			} else {
				var hitem = null;
				if( menu.menuItemHAlign != 'left' ) {
					if(window.mmIsOpera) {
						var operaWidth = menu.menuItemHAlign == 'center' ? -(menu.menuWidth-2*menu.menuItemPadding) : (menu.menuWidth-6*menu.menuItemPadding);
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					} else {
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					}
				} else hitem = null;
			}
			if(document.all && !window.mmIsOpera) item = '<div id="menuItemShim' + countItems + '" style="position:absolute;left:0px;top:0px;">' + item + '</div>';
			var dText	= '<div id="menuItemText'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColor +';">'+ item +'&nbsp</div>\n'
						+ '<div id="menuItemHilite'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColorHilite +';visibility:hidden;">' 
						+ (hitem||item) +'&nbsp</div>';
			if (childMenu) content += ( dTag + dText + '<div id="childMenu'+ countItems +'" style="position:absolute;left:0px;top:3px;"><img src="'+ menu.childMenuIcon +'"></div>\n' + dClose);
			else content += ( dTag + dText + dClose);
			if (lrs) {
				l.document.open("text/html");
				l.document.writeln(content);
				l.document.close();	
				content = '';
				theStat += "-";
				tsc++;
				if (tsc > 50) {
					tsc = 0;
					theStat = "";
				}
				status = theStat;
			}
			countItems++;  
		}
		if (lrs) {
			var focusItem = new Layer(100, body);
			focusItem.visiblity="hidden";
			focusItem.document.open("text/html");
			focusItem.document.writeln("&nbsp;");
			focusItem.document.close();	
		} else {
		  content += '	  <div id="focusItem'+ countMenus +'" style="position:absolute;left:0px;top:0px;visibility:hide;" onclick="onMenuItemAction(null,this);">&nbsp;</div>\n';
		  content += '   </div>\n  </div>\n</div>\n';
		}
		i=x;
	}
	if (document.layers) {		
		container.clip.width = window.innerWidth;
		container.clip.height = window.innerHeight;
		container.onmouseout = mouseoutMenu;
		container.menuContainerBgColor = this.menuContainerBgColor;
		for (var i=0; i<container.document.layers.length; i++) {
			proto = container.menus[i];
			var menu = container.document.layers[i];
			container.menus[i].menuLayer = menu;
			container.menus[i].menuLayer.Menu = container.menus[i];
			container.menus[i].menuLayer.Menu.container = container;
			var body = menu.document.layers[0].document.layers[0];
			body.clip.width = proto.menuWidth || body.clip.width;
			body.clip.height = proto.menuHeight || body.clip.height;
			for (var n=0; n<body.document.layers.length-1; n++) {
				var l = body.document.layers[n];
				l.Menu = container.menus[i];
				l.menuHiliteBgColor = proto.menuHiliteBgColor;
				l.document.bgColor = proto.menuItemBgColor;
				l.saveColor = proto.menuItemBgColor;
				l.onmouseover = proto.onMenuItemOver;
				l.onclick = proto.onMenuItemAction;
				l.mmaction = container.menus[i].actions[n];
				l.focusItem = body.document.layers[body.document.layers.length-1];
				l.clip.width = proto.menuWidth || body.clip.width;
				l.clip.height = proto.menuItemHeight || l.clip.height;
				if (n>0) {
					if( l.Menu.vertical ) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder + proto.menuItemSpacing;
					else l.left = body.document.layers[n-1].left + body.document.layers[n-1].clip.width + proto.menuItemBorder + proto.menuItemSpacing;
				}
				l.hilite = l.document.layers[1];
				if (proto.bgImageUp) l.background.src = proto.bgImageUp;
				l.document.layers[1].isHilite = true;
				if (l.document.layers.length > 2) {
					l.childMenu = container.menus[i].items[n].menuLayer;
					l.document.layers[2].left = l.clip.width -13;
					l.document.layers[2].top = (l.clip.height / 2) -4;
					l.document.layers[2].clip.left += 3;
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
			}
			if( proto.menuBgOpaque ) body.document.bgColor = proto.bgColor;
			if( proto.vertical ) {
				body.clip.width  = l.clip.width +proto.menuBorder;
				body.clip.height = l.top + l.clip.height +proto.menuBorder;
			} else {
				body.clip.height  = l.clip.height +proto.menuBorder;
				body.clip.width = l.left + l.clip.width  +proto.menuBorder;
				if( body.clip.width > window.innerWidth ) body.clip.width = window.innerWidth;
			}
			var focusItem = body.document.layers[n];
			focusItem.clip.width = body.clip.width;
			focusItem.Menu = l.Menu;
			focusItem.top = -30;
            focusItem.captureEvents(Event.MOUSEDOWN);
            focusItem.onmousedown = onMenuItemDown;
			if( proto.menuBgOpaque ) menu.document.bgColor = proto.menuBorderBgColor;
			var lite = menu.document.layers[0];
			if( proto.menuBgOpaque ) lite.document.bgColor = proto.menuLiteBgColor;
			lite.clip.width = body.clip.width +1;
			lite.clip.height = body.clip.height +1;
			menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
			menu.clip.height = body.clip.height + (proto.menuBorder * 3);
		}
	} else {
		if ((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) {
			container.innerHTML=content;
		} else {
			container.document.open("text/html");
			container.document.writeln(content);
			container.document.close();	
		}
		if (!FIND("menuLayer0")) return;
		var menuCount = 0;
		for (var x=0; x<container.menus.length; x++) {
			var menuLayer = FIND("menuLayer" + x);
			container.menus[x].menuLayer = "menuLayer" + x;
			menuLayer.Menu = container.menus[x];
			menuLayer.Menu.container = "menuLayer" + x;
			menuLayer.style.zindex = 1;
		    var s = menuLayer.style;
			s.pixeltop = -300;
			s.pixelleft = -300;
			s.top = '-300px';
			s.left = '-300px';

			var menu = container.menus[x];
			menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
			if( menu.menuBgOpaque ) menuLayer.style.backgroundColor = menu.menuBorderBgColor;
			var top = 0;
			var left = 0;
			menu.menuItemLayers = new Array();
			for (var i=0; i<container.menus[x].items.length; i++) {
				var l = FIND("menuItem" + menuCount);
				l.Menu = container.menus[x];
				l.Menu.menuItemLayers[l.Menu.menuItemLayers.length] = l;
				if (l.addEventListener || window.mmIsOpera) {
					l.style.width = menu.menuItemWidth + 'px';
					l.style.height = menu.menuItemHeight + 'px';
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.top = top + 'px';
					l.style.left = left + 'px';
					if(l.addEventListener) {
						l.addEventListener("mouseover", onMenuItemOver, false);
						l.addEventListener("click", onMenuItemAction, false);
						l.addEventListener("mouseout", mouseoutMenu, false);
					}
					if( menu.menuItemHAlign != 'left' ) {
						l.hiliteShim = FIND("menuItemHilite" + menuCount + "Shim");
						l.hiliteShim.style.visibility = "inherit";
						l.textShim = FIND("menuItemText" + menuCount + "Shim");
						l.hiliteShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.hiliteShim.style.width = l.hiliteShim.style.pixelWidth;
						l.textShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.textShim.style.width = l.textShim.style.pixelWidth;	
					}
				} else {
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.pixelTop = top;
					l.style.pixelLeft = left;
					if( menu.menuItemHAlign != 'left' ) {
						var shim = FIND("menuItemShim" + menuCount);
						shim[0].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[1].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[0].style.width = shim[0].style.pixelWidth + 'px';
						shim[1].style.width = shim[1].style.pixelWidth + 'px';
					}
				}
				if( menu.vertical ) top = top + menu.menuItemHeight+menu.menuItemBorder+menu.menuItemSpacing;
				else left = left + menu.menuItemWidth+menu.menuItemBorder+menu.menuItemSpacing;
				l.style.fontSize = menu.fontSize + 'px';
				l.style.backgroundColor = menu.menuItemBgColor;
				l.style.visibility = "inherit";
				l.saveColor = menu.menuItemBgColor;
				l.menuHiliteBgColor = menu.menuHiliteBgColor;
				l.mmaction = container.menus[x].actions[i];
				l.hilite = FIND("menuItemHilite" + menuCount);
				l.focusItem = FIND("focusItem" + x);
				l.focusItem.style.pixelTop = -30;
				l.focusItem.style.top = '-30px';
				var childItem = FIND("childMenu" + menuCount);
				if (childItem) {
					l.childMenu = container.menus[x].items[i].menuLayer;
					childItem.style.pixelLeft = menu.menuItemWidth -11;
					childItem.style.left = childItem.style.pixelLeft + 'px';
					childItem.style.pixelTop = (menu.menuItemHeight /2) -4;
					childItem.style.top = childItem.style.pixelTop + 'px';
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
				l.style.cursor = "hand";
				menuCount++;
			}
			if( menu.vertical ) {
				menu.menuHeight = top-1-menu.menuItemSpacing;
				menu.menuWidth = menu.menuItemWidth;
			} else {
				menu.menuHeight = menu.menuItemHeight;
				menu.menuWidth = left-1-menu.menuItemSpacing;
			}

			var lite = FIND("menuLite" + x);
			var s = lite.style;
			s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + (menu.menuBorder * 2);
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.menuLiteBgColor;

			var body = FIND("menuFg" + x);
			s = body.style;
			s.pixelHeight = menu.menuHeight + menu.menuBorder;
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + menu.menuBorder;
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.bgColor;

			s = menuLayer.style;
			s.pixelWidth  = menu.menuWidth + (menu.menuBorder * 4);
			s.width = s.pixelWidth + 'px';
			s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
			s.height = s.pixelHeight + 'px';
		}
	}
	if (document.captureEvents) document.captureEvents(Event.MOUSEUP);
	if (document.addEventListener) document.addEventListener("mouseup", onMenuItemOver, false);
	if (document.layers && window.innerWidth) {
		window.onresize = NS4resize;
		window.NS4sIW = window.innerWidth;
		window.NS4sIH = window.innerHeight;
		setTimeout("NS4resize()",500);
	}
	document.onmouseup = mouseupMenu;
	window.mmWroteMenu = true;
	status = "";
}

function NS4resize() {
	if (NS4sIW != window.innerWidth || NS4sIH != window.innerHeight) window.location.reload();
}

function onMenuItemOver(e, l) {
	MM_clearTimeout();
	l = l || this;
	a = window.ActiveMenuItem;
	if (document.layers) {
		if (a) {
			a.document.bgColor = a.saveColor;
			if (a.hilite) a.hilite.visibility = "hidden";
			if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
			a.focusItem.top = -100;
			a.clicked = false;
		}
		if (l.hilite) {
			l.document.bgColor = l.menuHiliteBgColor;
			l.zIndex = 1;
			l.hilite.visibility = "inherit";
			l.hilite.zIndex = 2;
			l.document.layers[1].zIndex = 1;
			l.focusItem.zIndex = this.zIndex +2;
		}
		if (l.Menu.bgImageOver) l.background.src = l.Menu.bgImageOver;
		l.focusItem.top = this.top;
		l.focusItem.left = this.left;
		l.focusItem.clip.width = l.clip.width;
		l.focusItem.clip.height = l.clip.height;
		l.Menu.hideChildMenu(l);
	} else if (l.style && l.Menu) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";;
		} 
		l.style.backgroundColor = l.menuHiliteBgColor;
		l.zIndex = 1;
		if (l.Menu.bgImageOver) l.style.background = "url(" + l.Menu.bgImageOver +")";
		if (l.hilite) {
			l.hilite.style.visibility = "inherit";
			if( l.hiliteShim ) l.hiliteShim.style.visibility = "visible";
		}
		l.focusItem.style.pixelTop = l.style.pixelTop;
		l.focusItem.style.top = l.focusItem.style.pixelTop + 'px';
		l.focusItem.style.pixelLeft = l.style.pixelLeft;
		l.focusItem.style.left = l.focusItem.style.pixelLeft + 'px';
		l.focusItem.style.zIndex = l.zIndex +1;
		l.Menu.hideChildMenu(l);
	} else return;
	window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
	l = window.ActiveMenuItem;
	if (!l) return;
	hideActiveMenus();
	if (l.mmaction) eval("" + l.mmaction);
	window.ActiveMenuItem = 0;
}

function MM_clearTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
	mmDHFlag = false;
}

function MM_startTimeout() {
	if( window.ActiveMenu ) {
		mmStart = new Date();
		mmDHFlag = true;
		mmHideMenuTimer = setTimeout("mmDoHide()", window.ActiveMenu.Menu.hideTimeout);
	}
}

function mmDoHide() {
	if (!mmDHFlag || !window.ActiveMenu) return;
	var elapsed = new Date() - mmStart;
	var timeout = window.ActiveMenu.Menu.hideTimeout;
	if (elapsed < timeout) {
		mmHideMenuTimer = setTimeout("mmDoHide()", timeout+100-elapsed);
		return;
	}
	mmDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}

function MM_showMenu(menu, x, y, child, imgname) {
	if (!window.mmWroteMenu) return;
	MM_clearTimeout();
	if (menu) {
		var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
		x = moveXbySlicePos (x, obj);
		y = moveYbySlicePos (y, obj);
	}
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.top = l.left = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) { 			   
			if (!l.layers[i].isHilite) l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) MM_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor && l.Menu.menuBgOpaque ) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;	
		hideActiveMenus();
		if (typeof(l) == "string") l = FIND(l);
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") {
			s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			s.left = s.pixelLeft + 'px';
		}
		if (y != "relative") {
			s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
			s.top = s.pixelTop + 'px';
		}
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) window.activeMenus[window.activeMenus.length] = l;
	MM_clearTimeout();
}

function onMenuItemDown(e, l) {
	var a = window.ActiveMenuItem;
	if (document.layers && a) {
		a.eX = e.pageX;
		a.eY = e.pageY;
		a.clicked = true;
    }
}

function mouseupMenu(e) {
	hideMenu(true, e);
	hideActiveMenus();
	return true;
}

function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

function mouseoutMenu() {
	if ((navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() < 4.5))
		return true;
	hideMenu(false, false);
	return true;
}

function hideMenu(mouseup, e) {
	var a = window.ActiveMenuItem;
	if (a && document.layers) {
		a.document.bgColor = a.saveColor;
		a.focusItem.top = -30;
		if (a.hilite) a.hilite.visibility = "hidden";
		if (mouseup && a.mmaction && a.clicked && window.ActiveMenu) {
 			if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10) {
				setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 500);
			}
		}
		a.clicked = false;
		if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
	} else if (window.ActiveMenu && FIND("menuItem0")) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";
		}
	}
	if (!mouseup && window.ActiveMenu) {
		if (window.ActiveMenu.Menu) {
			if (window.ActiveMenu.Menu.hideOnMouseOut) MM_startTimeout();
			return(true);
		}
	}
	return(true);
}

function hideChildMenu(hcmLayer) {
	MM_clearTimeout();
	var l = hcmLayer;
	for (var i=0; i < l.Menu.childMenus.length; i++) {
		var theLayer = l.Menu.childMenus[i];
		if (document.layers) theLayer.visibility = "hidden";
		else {
			theLayer = FIND(theLayer);
			theLayer.style.visibility = "hidden";
			if( theLayer.Menu.menuItemHAlign != 'left' ) {
				for(var j = 0; j < theLayer.Menu.menuItemLayers.length; j++) {
					var itemLayer = theLayer.Menu.menuItemLayers[j];
					if(itemLayer.textShim) itemLayer.textShim.style.visibility = "inherit";
				}
			}
		}
		theLayer.Menu.hideChildMenu(theLayer);
	}
	if (l.childMenu) {
		var childMenu = l.childMenu;
		if (document.layers) {
			l.Menu.MM_showMenu(null,null,null,childMenu.layers[0]);
			childMenu.zIndex = l.parentLayer.zIndex +1;
			childMenu.top = l.Menu.menuLayer.top + l.Menu.submenuYOffset;
			if( l.Menu.vertical ) {
				if( l.Menu.submenuRelativeToItem ) childMenu.top += l.top + l.parentLayer.top;
				childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			} else {
				childMenu.top += l.top + l.parentLayer.top;	
				if( l.Menu.submenuRelativeToItem ) childMenu.left = l.Menu.menuLayer.left + l.left + l.clip.width + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
				else childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			}
			if( childMenu.left < l.Menu.container.clip.left ) l.Menu.container.clip.left = childMenu.left;
			var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
			if (w > l.Menu.container.clip.width)  l.Menu.container.clip.width = w;
			var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
			if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
			l.document.layers[1].zIndex = 0;
			childMenu.visibility = "inherit";
		} else if (FIND("menuItem0")) {
			childMenu = FIND(l.childMenu);
			var menuLayer = FIND(l.Menu.menuLayer);
			var s = childMenu.style;
			s.zIndex = menuLayer.style.zIndex+1;
			if (document.all || window.mmIsOpera) {
				s.pixelTop = menuLayer.style.pixelTop + l.Menu.submenuYOffset;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) s.pixelTop += l.style.pixelTop;
					s.pixelLeft = l.style.pixelWidth + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				} else {
					s.pixelTop += l.style.pixelTop;
					if( l.Menu.submenuRelativeToItem ) s.pixelLeft = menuLayer.style.pixelLeft + l.style.pixelLeft + l.style.pixelWidth + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else s.pixelLeft = (menuLayer.style.pixelWidth-4*l.Menu.menuBorder) + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				}
			} else {
				var top = parseInt(menuLayer.style.top) + l.Menu.submenuYOffset;
				var left = 0;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) top += parseInt(l.style.top);
					left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				} else {
					top += parseInt(l.style.top);
					if( l.Menu.submenuRelativeToItem ) left = parseInt(menuLayer.style.left) + parseInt(l.style.left) + parseInt(l.style.width) + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				}
				s.top = top + 'px';
				s.left = left + 'px';
			}
			childMenu.style.visibility = "inherit";
		} else return;
		window.activeMenus[window.activeMenus.length] = childMenu;
	}
}

function hideActiveMenus() {
	if (!window.activeMenus) return;
	for (var i=0; i < window.activeMenus.length; i++) {
		if (!activeMenus[i]) continue;
		if (activeMenus[i].visibility && activeMenus[i].Menu && !window.mmIsOpera) {
			activeMenus[i].visibility = "hidden";
			activeMenus[i].Menu.container.visibility = "hidden";
			activeMenus[i].Menu.container.clip.left = 0;
		} else if (activeMenus[i].style) {
			var s = activeMenus[i].style;
			s.visibility = "hidden";
			s.left = '-200px';
			s.top = '-200px';
		}
	}
	if (window.ActiveMenuItem) hideMenu(false, false);
	window.activeMenus.length = 0;
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}





function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

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 MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
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 openWindow1(url) { popupWin = window.open(url, 'openWin', "width=400, height=250, scrollbars=yes, resizable=yes"); } 

function espanol(name,caption,bullet1,bullet2,bullet3,bullet4,bullet5)
{
if (bullet1.length<1)
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption
}
else if (bullet2.length<1)
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption+"<li>"+bullet1+"</li>"
}
else if (bullet3.length<1)
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption+"<li>"+bullet1+"</li>"+"<li>"+bullet2+"</li>"
}
else if (bullet4.length<1)
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption+"<li>"+bullet1+"</li>"+"<li>"+bullet2+"</li><li>"+bullet3+"</li>"
}
else if (bullet5.length<1)
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption+"<li>"+bullet1+"</li>"+"<li>"+bullet2+"</li><li>"+bullet3+"</li><li>"+bullet4+"</li>"
}

else
{
var txt="<strong>"+name+"</strong><br><br><font size=\"1\" face=\"arial, helvetica\">"+caption+"<li>"+bullet1+"</li>"+"<li>"+bullet2+"</li>"+"<li>"+bullet3+"</li>"+"<li>"+bullet4+"</li>"+"<li>"+bullet5+"</li></font>"

}

var p=window.createPopup()
var pbody=p.document.body
pbody.style.backgroundColor="white"
pbody.style.border="solid lime 1px"
pbody.style.padding="8px"
pbody.innerHTML=txt
p.show(550,150,250,350,document.body)
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Patrick Lewis (gtrwiz@aol.com) -->
<!-- Web Site:  http://www.patricklewis.net -->
<!-- Begin
//   ##############  SIMPLE  BROWSER SNIFFER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}


overdiv="0";
//  #########  CREATES POP UP BOXES 
function popBox(title,txt){
if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=ccff99";}
else {pad="1"; bord="1 bordercolor=ccff99";}
desc = 	  "<table width=200 cellspacing=0 cellpadding="+pad+" border="+bord+"  bgcolor=ffffff><tr><td>\n"
	+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td>"+title+"<br><font size=-1>\n"
	+txt
	+"\n</font></td></tr></table>\n"
	+"</td></tr></table>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x+15;
	document.object1.top=y-5;
	}
else if(navigator.family =="ie4"){
	object1.innerHTML=desc;
	object1.style.pixelLeft=x+15;
	object1.style.pixelTop=y-5;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x+15;
	document.getElementById("object1").style.top=y-5;
	}
}
function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
//  End -->
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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

/*******************************************************************************

 SpryMenuBar.js
 This file handles the JavaScript for Spry Menu Bar.  You should have no need
 to edit this file.  Some highlights of the MenuBar object is that timers are
 used to keep submenus from showing up until the user has hovered over the parent
 menu item for some time, as well as a timer for when they leave a submenu to keep
 showing that submenu until the timer fires.

 *******************************************************************************/

var Spry; if (!Spry) Spry = {}; if (!Spry.Widget) Spry.Widget = {};

Spry.BrowserSniff = function()
{
	var b = navigator.appName.toString();
	var up = navigator.platform.toString();
	var ua = navigator.userAgent.toString();

	this.mozilla = this.ie = this.opera = this.safari = false;
	var re_opera = /Opera.([0-9\.]*)/i;
	var re_msie = /MSIE.([0-9\.]*)/i;
	var re_gecko = /gecko/i;
	var re_safari = /(applewebkit|safari)\/([\d\.]*)/i;
	var r = false;

	if ( (r = ua.match(re_opera))) {
		this.opera = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_msie))) {
		this.ie = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_safari))) {
		this.safari = true;
		this.version = parseFloat(r[2]);
	} else if (ua.match(re_gecko)) {
		var re_gecko_version = /rv:\s*([0-9\.]+)/i;
		r = ua.match(re_gecko_version);
		this.mozilla = true;
		this.version = parseFloat(r[1]);
	}
	this.windows = this.mac = this.linux = false;

	this.Platform = ua.match(/windows/i) ? "windows" :
					(ua.match(/linux/i) ? "linux" :
					(ua.match(/mac/i) ? "mac" :
					ua.match(/unix/i)? "unix" : "unknown"));
	this[this.Platform] = true;
	this.v = this.version;

	if (this.safari && this.mac && this.mozilla) {
		this.mozilla = false;
	}
};

Spry.is = new Spry.BrowserSniff();

// Constructor for Menu Bar
// element should be an ID of an unordered list (<ul> tag)
// preloadImage1 and preloadImage2 are images for the rollover state of a menu
Spry.Widget.MenuBar = function(element, opts)
{
	this.init(element, opts);
};

Spry.Widget.MenuBar.prototype.init = function(element, opts)
{
	this.element = this.getElement(element);

	// represents the current (sub)menu we are operating on
	this.currMenu = null;
	this.showDelay = 250;
	this.hideDelay = 600;
	if(typeof document.getElementById == 'undefined' || (navigator.vendor == 'Apple Computer, Inc.' && typeof window.XMLHttpRequest == 'undefined') || (Spry.is.ie && typeof document.uniqueID == 'undefined'))
	{
		// bail on older unsupported browsers
		return;
	}

	// Fix IE6 CSS images flicker
	if (Spry.is.ie && Spry.is.version < 7){
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
	}

	this.upKeyCode = Spry.Widget.MenuBar.KEY_UP;
	this.downKeyCode = Spry.Widget.MenuBar.KEY_DOWN;
	this.leftKeyCode = Spry.Widget.MenuBar.KEY_LEFT;
	this.rightKeyCode = Spry.Widget.MenuBar.KEY_RIGHT;
	this.escKeyCode = Spry.Widget.MenuBar.KEY_ESC;

	this.hoverClass = 'MenuBarItemHover';
	this.subHoverClass = 'MenuBarItemSubmenuHover';
	this.subVisibleClass ='MenuBarSubmenuVisible';
	this.hasSubClass = 'MenuBarItemSubmenu';
	this.activeClass = 'MenuBarActive';
	this.isieClass = 'MenuBarItemIE';
	this.verticalClass = 'MenuBarVertical';
	this.horizontalClass = 'MenuBarHorizontal';
	this.enableKeyboardNavigation = true;

	this.hasFocus = false;
	// load hover images now
	if(opts)
	{
		for(var k in opts)
		{
			if (typeof this[k] == 'undefined')
			{
				var rollover = new Image;
				rollover.src = opts[k];
			}
		}
		Spry.Widget.MenuBar.setOptions(this, opts);
	}

	// safari doesn't support tabindex
	if (Spry.is.safari)
		this.enableKeyboardNavigation = false;

	if(this.element)
	{
		this.currMenu = this.element;
		var items = this.element.getElementsByTagName('li');
		for(var i=0; i<items.length; i++)
		{
			if (i > 0 && this.enableKeyboardNavigation)
				items[i].getElementsByTagName('a')[0].tabIndex='-1';

			this.initialize(items[i], element);
			if(Spry.is.ie)
			{
				this.addClassName(items[i], this.isieClass);
				items[i].style.position = "static";
			}
		}
		if (this.enableKeyboardNavigation)
		{
			var self = this;
			this.addEventListener(document, 'keydown', function(e){self.keyDown(e); }, false);
		}

		if(Spry.is.ie)
		{
			if(this.hasClassName(this.element, this.verticalClass))
			{
				this.element.style.position = "relative";
			}
			var linkitems = this.element.getElementsByTagName('a');
			for(var i=0; i<linkitems.length; i++)
			{
				linkitems[i].style.position = "relative";
			}
		}
	}
};
Spry.Widget.MenuBar.KEY_ESC = 27;
Spry.Widget.MenuBar.KEY_UP = 38;
Spry.Widget.MenuBar.KEY_DOWN = 40;
Spry.Widget.MenuBar.KEY_LEFT = 37;
Spry.Widget.MenuBar.KEY_RIGHT = 39;

Spry.Widget.MenuBar.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.MenuBar.prototype.hasClassName = function(ele, className)
{
	if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1)
	{
		return false;
	}
	return true;
};

Spry.Widget.MenuBar.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || this.hasClassName(ele, className))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.MenuBar.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || !this.hasClassName(ele, className))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

// addEventListener for Menu Bar
// attach an event to a tag without creating obtrusive HTML code
Spry.Widget.MenuBar.prototype.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
		{
			element.addEventListener(eventType, handler, capture);
		}
		else if (element.attachEvent)
		{
			element.attachEvent('on' + eventType, handler);
		}
	}
	catch (e) {}
};

// createIframeLayer for Menu Bar
// creates an IFRAME underneath a menu so that it will show above form controls and ActiveX
Spry.Widget.MenuBar.prototype.createIframeLayer = function(menu)
{
	var layer = document.createElement('iframe');
	layer.tabIndex = '-1';
	layer.src = 'javascript:""';
	layer.frameBorder = '0';
	layer.scrolling = 'no';
	menu.parentNode.appendChild(layer);
	
	layer.style.left = menu.offsetLeft + 'px';
	layer.style.top = menu.offsetTop + 'px';
	layer.style.width = menu.offsetWidth + 'px';
	layer.style.height = menu.offsetHeight + 'px';
};

// removeIframeLayer for Menu Bar
// removes an IFRAME underneath a menu to reveal any form controls and ActiveX
Spry.Widget.MenuBar.prototype.removeIframeLayer =  function(menu)
{
	var layers = ((menu == this.element) ? menu : menu.parentNode).getElementsByTagName('iframe');
	while(layers.length > 0)
	{
		layers[0].parentNode.removeChild(layers[0]);
	}
};

// clearMenus for Menu Bar
// root is the top level unordered list (<ul> tag)
Spry.Widget.MenuBar.prototype.clearMenus = function(root)
{
	var menus = root.getElementsByTagName('ul');
	for(var i=0; i<menus.length; i++)
		this.hideSubmenu(menus[i]);

	this.removeClassName(this.element, this.activeClass);
};

// bubbledTextEvent for Menu Bar
// identify bubbled up text events in Safari so we can ignore them
Spry.Widget.MenuBar.prototype.bubbledTextEvent = function()
{
	return Spry.is.safari && (event.target == event.relatedTarget.parentNode || (event.eventPhase == 3 && event.target.parentNode == event.relatedTarget));
};

// showSubmenu for Menu Bar
// set the proper CSS class on this menu to show it
Spry.Widget.MenuBar.prototype.showSubmenu = function(menu)
{
	if(this.currMenu)
	{
		this.clearMenus(this.currMenu);
		this.currMenu = null;
	}
	
	if(menu)
	{
		this.addClassName(menu, this.subVisibleClass);
		if(typeof document.all != 'undefined' && !Spry.is.opera && navigator.vendor != 'KDE')
		{
			if(!this.hasClassName(this.element, this.horizontalClass) || menu.parentNode.parentNode != this.element)
			{
				menu.style.top = menu.parentNode.offsetTop + 'px';
			}
		}
		if(Spry.is.ie && Spry.is.version < 8)
		{
			this.createIframeLayer(menu);
		}
	}
	this.addClassName(this.element, this.activeClass);
	 // document.getElementById('reviewloader').style.visibility = 'hidden';
      //document.getElementById('ratings').style.visibility = 'hidden';

};

// hideSubmenu for Menu Bar
// remove the proper CSS class on this menu to hide it
Spry.Widget.MenuBar.prototype.hideSubmenu = function(menu)
{
	if(menu)
	{
		this.removeClassName(menu, this.subVisibleClass);
		if(typeof document.all != 'undefined' && !Spry.is.opera && navigator.vendor != 'KDE')
		{
			menu.style.top = '';
			menu.style.left = '';
		}
		if(Spry.is.ie && Spry.is.version < 8)
			this.removeIframeLayer(menu);
	}
		  //document.getElementById('reviewloader').style.visibility = 'visible';
      //document.getElementById('ratings').style.visibility = 'visible';

};

// initialize for Menu Bar
// create event listeners for the Menu Bar widget so we can properly
// show and hide submenus
Spry.Widget.MenuBar.prototype.initialize = function(listitem, element)
{
	var opentime, closetime;
	var link = listitem.getElementsByTagName('a')[0];
	var submenus = listitem.getElementsByTagName('ul');
	var menu = (submenus.length > 0 ? submenus[0] : null);

	if(menu)
		this.addClassName(link, this.hasSubClass);

	if(!Spry.is.ie)
	{
		// define a simple function that comes standard in IE to determine
		// if a node is within another node
		listitem.contains = function(testNode)
		{
			// this refers to the list item
			if(testNode == null)
				return false;

			if(testNode == this)
				return true;
			else
				return this.contains(testNode.parentNode);
		};
	}

	// need to save this for scope further down
	var self = this;
	this.addEventListener(listitem, 'mouseover', function(e){self.mouseOver(listitem, e);}, false);
	this.addEventListener(listitem, 'mouseout', function(e){if (self.enableKeyboardNavigation) self.clearSelection(); self.mouseOut(listitem, e);}, false);

	if (this.enableKeyboardNavigation)
	{
		this.addEventListener(link, 'blur', function(e){self.onBlur(listitem);}, false);
		this.addEventListener(link, 'focus', function(e){self.keyFocus(listitem, e);}, false);
	}
};
Spry.Widget.MenuBar.prototype.keyFocus = function (listitem, e)
{
	this.lastOpen = listitem.getElementsByTagName('a')[0];
	this.addClassName(this.lastOpen, listitem.getElementsByTagName('ul').length > 0 ? this.subHoverClass : this.hoverClass);
	this.hasFocus = true;
};
Spry.Widget.MenuBar.prototype.onBlur = function (listitem)
{
	this.clearSelection(listitem);
};
Spry.Widget.MenuBar.prototype.clearSelection = function(el){
	//search any intersection with the current open element
	if (!this.lastOpen)
		return;

	if (el)
	{
		el = el.getElementsByTagName('a')[0];
		
		// check children
		var item = this.lastOpen;
		while (item != this.element)
		{
			var tmp = el;
			while (tmp != this.element)
			{
				if (tmp == item)
					return;
				try{
					tmp = tmp.parentNode;
				}catch(err){break;}
			}
			item = item.parentNode;
		}
	}
	var item = this.lastOpen;
	while (item != this.element)
	{
		this.hideSubmenu(item.parentNode);
		var link = item.getElementsByTagName('a')[0];
		this.removeClassName(link, this.hoverClass);
		this.removeClassName(link, this.subHoverClass);
		item = item.parentNode;
	}
	this.lastOpen = false;
};
Spry.Widget.MenuBar.prototype.keyDown = function (e)
{
	if (!this.hasFocus)
		return;

	if (!this.lastOpen)
	{
		this.hasFocus = false;
		return;
	}

	var e = e|| event;
	var listitem = this.lastOpen.parentNode;
	var link = this.lastOpen;
	var submenus = listitem.getElementsByTagName('ul');
	var menu = (submenus.length > 0 ? submenus[0] : null);
	var hasSubMenu = (menu) ? true : false;

	var opts = [listitem, menu, null, this.getSibling(listitem, 'previousSibling'), this.getSibling(listitem, 'nextSibling')];
	
	if (!opts[3])
		opts[2] = (listitem.parentNode.parentNode.nodeName.toLowerCase() == 'li')?listitem.parentNode.parentNode:null;

	var found = 0;
	switch (e.keyCode){
		case this.upKeyCode:
			found = this.getElementForKey(opts, 'y', 1);
			break;
		case this.downKeyCode:
			found = this.getElementForKey(opts, 'y', -1);
			break;
		case this.leftKeyCode:
			found = this.getElementForKey(opts, 'x', 1);
			break;
		case this.rightKeyCode:
			found = this.getElementForKey(opts, 'x', -1);
			break;
		case this.escKeyCode:
		case 9:
			this.clearSelection();
			this.hasFocus = false;
		default: return;
	}
	switch (found)
	{
		case 0: return;
		case 1:
			//subopts
			this.mouseOver(listitem, e);
			break;
		case 2:
			//parent
			this.mouseOut(opts[2], e);
			break;
		case 3:
		case 4:
			// left - right
			this.removeClassName(link, hasSubMenu ? this.subHoverClass : this.hoverClass);
			break;
	}
	var link = opts[found].getElementsByTagName('a')[0];
	if (opts[found].nodeName.toLowerCase() == 'ul')
		opts[found] = opts[found].getElementsByTagName('li')[0];

	this.addClassName(link, opts[found].getElementsByTagName('ul').length > 0 ? this.subHoverClass : this.hoverClass);
	this.lastOpen = link;
	opts[found].getElementsByTagName('a')[0].focus();
  
        //stop further event handling by the browser
	return Spry.Widget.MenuBar.stopPropagation(e);
};
Spry.Widget.MenuBar.prototype.mouseOver = function (listitem, e)
{
	var link = listitem.getElementsByTagName('a')[0];
	var submenus = listitem.getElementsByTagName('ul');
	var menu = (submenus.length > 0 ? submenus[0] : null);
	var hasSubMenu = (menu) ? true : false;
	if (this.enableKeyboardNavigation)
		this.clearSelection(listitem);

	if(this.bubbledTextEvent())
	{
		// ignore bubbled text events
		return;
	}

	if (listitem.closetime)
		clearTimeout(listitem.closetime);

	if(this.currMenu == listitem)
	{
		this.currMenu = null;
	}

	// move the focus too
	if (this.hasFocus)
		link.focus();

	// show menu highlighting
	this.addClassName(link, hasSubMenu ? this.subHoverClass : this.hoverClass);
	this.lastOpen = link;
	if(menu && !this.hasClassName(menu, this.subHoverClass))
	{
		var self = this;
		listitem.opentime = window.setTimeout(function(){self.showSubmenu(menu);}, this.showDelay);
	}
};
Spry.Widget.MenuBar.prototype.mouseOut = function (listitem, e)
{
	var link = listitem.getElementsByTagName('a')[0];
	var submenus = listitem.getElementsByTagName('ul');
	var menu = (submenus.length > 0 ? submenus[0] : null);
	var hasSubMenu = (menu) ? true : false;
	if(this.bubbledTextEvent())
	{
		// ignore bubbled text events
		return;
	}

	var related = (typeof e.relatedTarget != 'undefined' ? e.relatedTarget : e.toElement);
	if(!listitem.contains(related))
	{
		if (listitem.opentime) 
			clearTimeout(listitem.opentime);
		this.currMenu = listitem;

		// remove menu highlighting
		this.removeClassName(link, hasSubMenu ? this.subHoverClass : this.hoverClass);
		if(menu)
		{
			var self = this;
			listitem.closetime = window.setTimeout(function(){self.hideSubmenu(menu);}, this.hideDelay);
		}
		if (this.hasFocus)
			link.blur();
	}
};
Spry.Widget.MenuBar.prototype.getSibling = function(element, sibling)
{
	var child = element[sibling];
	while (child && child.nodeName.toLowerCase() !='li')
		child = child[sibling];

	return child;
};
Spry.Widget.MenuBar.prototype.getElementForKey = function(els, prop, dir)
{
	var found = 0;
	var rect = Spry.Widget.MenuBar.getPosition;
	var ref = rect(els[found]);

	var hideSubmenu = false;
	//make the subelement visible to compute the position
	if (els[1] && !this.hasClassName(els[1], this.MenuBarSubmenuVisible))
	{
		els[1].style.visibility = 'hidden';
		this.showSubmenu(els[1]);
		hideSubmenu = true;
	}

	var isVert = this.hasClassName(this.element, this.verticalClass);
	var hasParent = els[0].parentNode.parentNode.nodeName.toLowerCase() == 'li' ? true : false;
	
	for (var i = 1; i < els.length; i++){
		//when navigating on the y axis in vertical menus, ignore children and parents
		if(prop=='y' && isVert && (i==1 || i==2))
		{
			continue;
		}
		//when navigationg on the x axis in the FIRST LEVEL of horizontal menus, ignore children and parents
		if(prop=='x' && !isVert && !hasParent && (i==1 || i==2))
		{
			continue;
		}
			
		if (els[i])
		{
			var tmp = rect(els[i]); 
			if ( (dir * tmp[prop]) < (dir * ref[prop]))
			{
				ref = tmp;
				found = i;
			}
		}
	}
	
	// hide back the submenu
	if (els[1] && hideSubmenu){
		this.hideSubmenu(els[1]);
		els[1].style.visibility =  '';
	}

	return found;
};
Spry.Widget.MenuBar.camelize = function(str)
{
	if (str.indexOf('-') == -1){
		return str;	
	}
	var oStringList = str.split('-');
	var isFirstEntry = true;
	var camelizedString = '';

	for(var i=0; i < oStringList.length; i++)
	{
		if(oStringList[i].length>0)
		{
			if(isFirstEntry)
			{
				camelizedString = oStringList[i];
				isFirstEntry = false;
			}
			else
			{
				var s = oStringList[i];
				camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
			}
		}
	}

	return camelizedString;
};

Spry.Widget.MenuBar.getStyleProp = function(element, prop)
{
	var value;
	try
	{
		if (element.style)
			value = element.style[Spry.Widget.MenuBar.camelize(prop)];

		if (!value)
			if (document.defaultView && document.defaultView.getComputedStyle)
			{
				var css = document.defaultView.getComputedStyle(element, null);
				value = css ? css.getPropertyValue(prop) : null;
			}
			else if (element.currentStyle) 
			{
					value = element.currentStyle[Spry.Widget.MenuBar.camelize(prop)];
			}
	}
	catch (e) {}

	return value == 'auto' ? null : value;
};
Spry.Widget.MenuBar.getIntProp = function(element, prop)
{
	var a = parseInt(Spry.Widget.MenuBar.getStyleProp(element, prop),10);
	if (isNaN(a))
		return 0;
	return a;
};

Spry.Widget.MenuBar.getPosition = function(el, doc)
{
	doc = doc || document;
	if (typeof(el) == 'string') {
		el = doc.getElementById(el);
	}

	if (!el) {
		return false;
	}

	if (el.parentNode === null || Spry.Widget.MenuBar.getStyleProp(el, 'display') == 'none') {
		//element must be visible to have a box
		return false;
	}

	var ret = {x:0, y:0};
	var parent = null;
	var box;

	if (el.getBoundingClientRect) { // IE
		box = el.getBoundingClientRect();
		var scrollTop = doc.documentElement.scrollTop || doc.body.scrollTop;
		var scrollLeft = doc.documentElement.scrollLeft || doc.body.scrollLeft;
		ret.x = box.left + scrollLeft;
		ret.y = box.top + scrollTop;
	} else if (doc.getBoxObjectFor) { // gecko
		box = doc.getBoxObjectFor(el);
		ret.x = box.x;
		ret.y = box.y;
	} else { // safari/opera
		ret.x = el.offsetLeft;
		ret.y = el.offsetTop;
		parent = el.offsetParent;
		if (parent != el) {
			while (parent) {
				ret.x += parent.offsetLeft;
				ret.y += parent.offsetTop;
				parent = parent.offsetParent;
			}
		}
		// opera & (safari absolute) incorrectly account for body offsetTop
		if (Spry.is.opera || Spry.is.safari && Spry.Widget.MenuBar.getStyleProp(el, 'position') == 'absolute')
			ret.y -= doc.body.offsetTop;
	}
	if (el.parentNode)
			parent = el.parentNode;
	else
		parent = null;
	if (parent.nodeName){
		var cas = parent.nodeName.toUpperCase();
		while (parent && cas != 'BODY' && cas != 'HTML') {
			cas = parent.nodeName.toUpperCase();
			ret.x -= parent.scrollLeft;
			ret.y -= parent.scrollTop;
			if (parent.parentNode)
				parent = parent.parentNode;
			else
				parent = null;
		}
	}
	return ret;
};

Spry.Widget.MenuBar.stopPropagation = function(ev)
{
	if (ev.stopPropagation)
		ev.stopPropagation();
	else
		ev.cancelBubble = true;
	if (ev.preventDefault) 
		ev.preventDefault();
	else 
		ev.returnValue = false;
};

Spry.Widget.MenuBar.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};





// SpryRating.js - version 0.2 - Spry Pre-Release 1.6.1
//
// Copyright (c) 2007. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//   * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//   * Neither the name of Adobe Systems Incorporated nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

//fix IE6 flicker bug - only once per browser session
try 
{
		document.execCommand("BackgroundImageCache", false, true);
} 
catch(err){}
  
var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

// Rating widget

Spry.Widget.Rating = function(element, opts)
{
	Spry.Widget.Rating.Notifier.call(this);

	//initialize object
	this.init(element, opts);
};

Spry.Widget.Rating.KEY_ENTER = 13;
Spry.Widget.Rating.KEY_LEFT = 37;
Spry.Widget.Rating.KEY_RIGHT = 39;

//Notifier mechanism 

Spry.Widget.Rating.Notifier = function()
{
	this.observers = [];
	this.suppressNotifications = 0;
};

Spry.Widget.Rating.Notifier.prototype.addObserver = function(observer)
{
	if (!observer)
		return;

	// Make sure the observer isn't already on the list.
	var len = this.observers.length;
	for (var i = 0; i < len; i++)
		if (this.observers[i] == observer) return;

	this.observers[len] = observer;
};

Spry.Widget.Rating.Notifier.prototype.removeObserver = function(observer)
{
	if (!observer)
		return;

	for (var i = 0; i < this.observers.length; i++)
	{
		if (this.observers[i] == observer)
		{
			this.observers.splice(i, 1);
			break;
		}
	}
};

Spry.Widget.Rating.Notifier.prototype.notifyObservers = function(methodName, data)
{
	if (!methodName)
		return;

	if (!this.suppressNotifications)
	{
		var len = this.observers.length;
		for (var i = 0; i < len; i++)
		{
			var obs = this.observers[i];
			if (obs)
			{
				if (typeof obs == "function")
				{
					obs(methodName, this, data);
				}
				else if (obs[methodName])
				{
					obs[methodName](this, data);
				}
			}
		}
	}
};

Spry.Widget.Rating.Notifier.prototype.enableNotifications = function()
{
	if (--this.suppressNotifications < 0)
	{
		this.suppressNotifications = 0;
		Spry.Effect.Rating.showError("Unbalanced enableNotifications() call!\n");
	}
};

Spry.Widget.Rating.Notifier.prototype.disableNotifications = function()
{
	++this.suppressNotifications;
};

Spry.Widget.Rating.prototype = new Spry.Widget.Rating.Notifier();
Spry.Widget.Rating.prototype.constructor = Spry.Widget.Rating;

Spry.Widget.Rating.prototype.init = function(element, opts)
{
	this.element = this.getElement(element);

	//CSS states
	this.containerInitialClass = 'ratingInitialState';
	this.containerReadOnlyClass = 'ratingReadOnlyState';
	this.containerRatedClass = 'ratingRatedState';
	this.readOnlyErrClass = 'ratingReadOnlyErrState';
	this.starDefaultClass = 'ratingButton';
	this.starFullClass = 'ratingFull';
	this.starHalfClass = 'ratingHalf';
	this.starEmptyClass = 'ratingEmpty';
	this.starHoverClass = 'ratingHover';
	this.counterClass = 'ratingCounter';

	//key codes
	this.movePrevKeyCode = Spry.Widget.Rating.KEY_LEFT;
	this.moveNextKeyCode = Spry.Widget.Rating.KEY_RIGHT;
	this.doRatingKeyCode = Spry.Widget.Rating.KEY_ENTER;

	//provide some sensible defaults
	this.afterRating = 'currentValue';
	this.enableKeyboardNavigation = true;
	this.allowMultipleRating = true;
	this.method = 'GET';
	this.postData = null;
	this.ratingValueElement = null;
	this.ratingValue = 0;
	this.saveUrl = null;
	this.hasFocus = null;
	this.rateHandler = null;

	//set all opts as properties on this object, overriding defaults
	Spry.Widget.Rating.setOptions(this, opts, true);

	this.stars = Spry.Widget.Rating.getElementsByClassName(this.element,this.starDefaultClass);
	
	if (this.stars.length == 0)
	{
		this.showError('No star elements in the container ' + (typeof element == 'string' ? element : ''));
		return;
	}

	//store rating value on each star
	for (var i=0; i < this.stars.length; i++)
		this.stars[i].starValue = i+1;
		
	if (this.saveUrl && this.postData)
		this.method = 'POST';

	//no element provided for initial value
	if(this.ratingValueElement)
	{
		this.ratingValueElement = this.getElement(this.ratingValueElement);
		this.ratingValue = parseFloat(this.ratingValueElement.getAttribute('value'));

		if (isNaN(this.ratingValue))
			this.ratingValue = 0;
	}

	//throw error if the number of stars is not at least 2
	if(this.stars.length < 2)
	{
		this.showError("The rating widget must have at least two stars!");
		return;
	}
	
	//throw error if ratingValue is greater than the number of stars
	if(this.ratingValue > this.stars.length)
	{
		this.showError("Rating initial value must not exceed the number of stars!");
		return;
	}

	//setup counter if requested
	if(this.counter)
	{
		this.updateCounter(this.ratingValue);
	}

	//color stars accordingly
	this.setValue(this.ratingValue); //don't try to update the linked input value
	
	//set default CSS class
	if(this.readOnly)
		this.setState('readonly');
	else
		this.setState('initial');

	//attach behaviors
	this.attachBehaviors();
};

//get current widget state
Spry.Widget.Rating.prototype.getState = function()
{
	return this.currentState;
};

//set container state: {initial|readonly|rated}
Spry.Widget.Rating.prototype.setState = function(state)
{
	var className;
	this.currentState = state;
		
	//ensure only the requested state is set		
	this.removeClassName(this.element,this.containerInitialClass);
	this.removeClassName(this.element,this.containerReadOnlyClass);
	this.removeClassName(this.element,this.containerRatedClass);
	
	switch(state)
	{
		case 'readonly': 
			className = this.containerReadOnlyClass; 
			break;
		case 'rated': 
			className = this.containerRatedClass;
			if (!this.allowMultipleRating)
			{
				this.addClassName(this.element,this.containerReadOnlyClass);
				state = 'readonly';
			}
			break;
		default:
			state = 'initial'; 
			className = this.containerInitialClass; 
			break;
	}

	this.addClassName(this.element,className);
};

Spry.Widget.Rating.prototype.removeMessage = function(className, when)
{
	switch(className)
	{
		case this.readOnlyErrClass:
		case this.containerRatedClass:
			if (!when)
				this.removeClassName(this.element,className);
			else
			{
				var self = this;
				setTimeout(function(){self.removeClassName(self.element, className);
					if (className == self.containerRatedClass && self.containerRatedClass != 'readonly'){
						//the container must have a state
						self.addClassName(self.element,self.containerInitialClass);
					}
				}, when);
			}		  
			break;
	}
};

Spry.Widget.Rating.prototype.attachBehaviors = function()
{
	//store event handlers here so we can detach them later
	this.event_handlers = [];

	// create event listeners for each star
	for(var j = 0; j < this.stars.length; j++)
	{
		var self = this;
		var star = this.stars[j];

		this.event_handlers.push([star, "click", function(e){self.onRate(e || event); }]);
		if(!this.readOnly)
		{
			this.event_handlers.push([star, "mouseover", function(e){self.onFocus(e || event); }]);
			this.event_handlers.push([star, "mouseout", function(e){self.onBlur(e || event); }]);
		}
		this.enableKeyboardNavigation = (this.enableKeyboardNavigation && star.attributes.getNamedItem("tabindex"));
		if (this.enableKeyboardNavigation && !this.readOnly){
			this.event_handlers.push([star, "focus", function(e){self.onFocus(e || event); }]);
			this.event_handlers.push([star, "blur", function(e){self.onBlur(e || event); }]);
			this.event_handlers.push([star, "keydown", function(e){self.keyDown(e || event); }]);			
		}
	}

	//actually register handlers
	for (var i=0; i<this.event_handlers.length; i++)
		Spry.Widget.Rating.addEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);

	//onunload handler
	Spry.Widget.Rating.addEventListener(window, "unload", this.destroy, false);
};

//get current widget value
Spry.Widget.Rating.prototype.getValue = function()
{
	return this.ratingValue;
};

// set value for all stars in the widget and update the linked input if requested
Spry.Widget.Rating.prototype.setValue = function(rating)
{
	if(this.ratingValueElement)
		this.ratingValueElement.value = rating;

	this.ratingValue = rating;

	this.updateCounter(this.ratingValue);

	for (var j = 0; j < this.stars.length; j++)
	{
		this.resetClasses(this.stars[j]);

		if (rating >= 1)
		{
			this.addClassName(this.stars[j], this.starFullClass);
			rating--;
		}
		else if(rating >= 0.5 && rating < 1)
		{
			this.addClassName(this.stars[j], this.starHalfClass);
			rating = 0;
		}
		else
		{
			this.addClassName(this.stars[j], this.starEmptyClass);
		}
	}
};

//onmouseover event handler
Spry.Widget.Rating.prototype.onFocus = function(e)
{
	this.hasFocus = true;	
	if( this.currentState === 'readonly' || (this.currentState === 'rated' && !this.allowMultipleRating))
		return;

	var target = (e.target) ? e.target : e.srcElement;

	for (var k = 0; k <= target.starValue; k++)
		this.addClassName(this.stars[k-1], this.starHoverClass);

	this.updateCounter(k-1);
};

//onblur event handler
Spry.Widget.Rating.prototype.onBlur = function(e)
{
	this.hasFocus = false;
	if(this.currentState === 'readonly' || (this.currentState === 'rated' && !this.allowMultipleRating))
		return;

	var target = (e.target) ? e.target : e.srcElement;

	for(var k = 0; k <= target.starValue; k++)
		this.removeClassName(this.stars[k-1], this.starHoverClass);

	this.updateCounter(this.ratingValue);
};

// rating event handler
Spry.Widget.Rating.prototype.onRate = function(e)
{
	this.notifyObservers("onPreRate");
	
	if(this.currentState == 'rated' && !this.allowMultipleRating)
		return;
	
	// if in readonly print an error
	// this message can be deleted later via an observer
	if(this.currentState == 'readonly')
	{
		this.removeClassName(this.element,this.containerRatedClass);
		this.addClassName(this.element,this.readOnlyErrClass);
		return;
	}
	
	this.setState('rated');

	var target = (e.target) ? e.target : e.srcElement;

	//set the rated value as the new widget value
	this.setValue(target.starValue);
	
	// call the callback functions in order (Spry, then user provided) 
	try{
		if(this.saveUrl)
			this.saveUrlHandler(target.starValue);
		if(typeof this.rateHandler=='function')
			this.rateHandler();
	}	
	catch(err){	
		this.showError(err);
	};

	this.notifyObservers("onPostRate");
};

//keydown event handler
Spry.Widget.Rating.prototype.keyDown = function(e)
{
	if(this.currentState == 'rated' && !this.allowMultipleRating)
		return;

	var key = e.keyCode;
	if (!this.hasFocus || (key != this.movePrevKeyCode && key != this.moveNextKeyCode && key != this.doRatingKeyCode))
		return true;
	
	var target = (e.target) ? e.target : e.srcElement;
	var j = target.starValue - 1;	//star position, 0-based

	switch(key)
	{
		case this.movePrevKeyCode:
			if(j > 0)
				this.stars[j-1].focus();
			break;
		case this.moveNextKeyCode:
			if(j < this.stars.length-1)
				this.stars[j+1].focus();
			break;
		case this.doRatingKeyCode:
			this.onRate(e);
			break;
		default: 
			break;
	}
	
	//stop further event handling by the browser
	return Spry.Widget.Rating.stopEvent(e);
};

//update rating counter innerHTML
Spry.Widget.Rating.prototype.updateCounter = function(val)
{
  if(this.counter)
  {    
	this.ratingCounter =  Spry.Widget.Rating.getElementsByClassName(this.element,this.counterClass)[0];
	this.ratingCounter.innerHTML = '[' + val + '/' + this.stars.length + ']';
  }
};

//save data - Spry provided
Spry.Widget.Rating.prototype.saveUrlHandler = function(val)
{
	//replace value into url / postdata, keep initial values for reuse
	this.newSaveUrl = this.saveUrl.replace(/@@ratingValue@@/,val);

	var opts = {};
	
	if(this.postData){
		this.newPostData = this.postData.replace(/@@ratingValue@@/,val);
		opts.headers = {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"};
		opts.postData = this.newPostData;	
	}

	var self = this;
	opts.errorCallback = function(req){self.onLoadError(req);};
	this.pendingRequest = Spry.Widget.Rating.loadURL(this.method, this.newSaveUrl, true, function(req){self.onLoadSuccess(req, val); }, opts);
};

//callback for success server operation
Spry.Widget.Rating.prototype.onLoadSuccess = function(req, val)
{
	this.notifyObservers("onServerUpdate", req);
		
	 //update myself with server value	
	if(this.afterRating == 'serverValue'){
		var returnVal = parseFloat(req.xhRequest.responseText);
		if (!isNaN(returnVal))
			this.setValue(returnVal);
	}
};

//callback for error server operation
Spry.Widget.Rating.prototype.onLoadError = function(req)
{
	this.notifyObservers("onServerError", req);
};

Spry.Widget.Rating.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.Rating.prototype.destroy = function()
{
	if (this.event_handlers)
		for (var i=0; i<this.event_handlers.length; i++)
		{
			Spry.Widget.Rating.removeEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
		}
	try { delete this.element; } catch(err) {}
	try { delete this.stars; } catch(err) {}
	try { delete this.counter; } catch(err) {}
	try { delete this.ratingValueElement; } catch(err) {}
	try { delete this.event_handlers; } catch(err) {}
};

/** CSS class manipulation
 *
 */
Spry.Widget.Rating.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.Rating.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.Rating.prototype.resetClasses = function(el)
{
	var cls = [ this.starFullClass, this.starHalfClass, this.starEmptyClass, this.starHoverClass ];
	for (var i=0; i < cls.length; i++)
		this.removeClassName(el, cls[i]);
};

Spry.Widget.Rating.prototype.showError = function(msg)
{
	alert('Spry.Widget.Rating ERROR: ' + msg);
};

/**
 *  Common utility functions
*/

//add event listener
Spry.Widget.Rating.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler, capture);
	}
	catch (e){}
};

//remove event listener
Spry.Widget.Rating.removeEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.removeEventListener)
			element.removeEventListener(eventType, handler, capture);
		else if (element.detachEvent)
			element.detachEvent("on" + eventType, handler, capture);
	}
	catch (e){}
};

Spry.Widget.Rating.hasClassName = function(ele, className)
{
	if (typeof element == 'string')
		element = document.getElementById(element);
	if (!ele || !className || !ele.className || ele.className.search(new RegExp("\\b" + className + "\\b")) == -1){
		return false;
			}
	return true;
};

Spry.Widget.Rating.getElementsByClassName = function(root, className)
{
  var results = [];
  var elements = root.getElementsByTagName("*");
  for (var i = 0; i < elements.length; i++){
	if (Spry.Widget.Rating.hasClassName(elements[i], className))    
	  results.push(elements[i]);
		}
  return results;
};

Spry.Widget.Rating.stopEvent = function(e)
{
	if (e.preventDefault) e.preventDefault();
	else e.returnValue = false;
	if (e.stopPropagation) e.stopPropagation();
	else e.cancelBubble = true;

	return false;
};

Spry.Widget.Rating.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;

	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

//loadURL utility functions

Spry.Widget.Rating.msProgIDs = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0"];

Spry.Widget.Rating.createXMLHttpRequest = function()
{
	var req = null;
	try
	{
		// Try to use the ActiveX version of XMLHttpRequest. This will
		// allow developers to load file URLs in IE7 when running in the
		// local zone.
		if (window.ActiveXObject)
		{
			while (!req && Spry.Widget.Rating.msProgIDs.length)
			{
				try { req = new ActiveXObject(Spry.Widget.Rating.msProgIDs[0]); } catch (e){ req = null; }
				if (!req)
					Spry.Widget.Rating.msProgIDs.splice(0, 1);
			}
		}
		// We're either running in a non-IE browser, or we failed to
		// create the ActiveX version of the XMLHttpRequest object.
		// Try to use the native version of XMLHttpRequest if it exists.

		if (!req && window.XMLHttpRequest)
			req = new XMLHttpRequest();
	}
	catch (e){ req = null; }

	if (!req)
		Spry.Widget.Rating.prototype.showError("Failed to create an XMLHttpRequest object!" );		

	return req;
};

Spry.Widget.Rating.loadURL = function(method, url, async, callback, opts)
{
	var req = new Spry.Widget.Rating.loadURL.Request();
	req.method = method;
	req.url = url;
	req.async = async;
	req.successCallback = callback;
	Spry.Widget.Rating.setOptions(req, opts);

	try
	{
		req.xhRequest = Spry.Widget.Rating.createXMLHttpRequest();
		if (!req.xhRequest)
			return null;

		if (req.async)
			req.xhRequest.onreadystatechange = function(){ Spry.Widget.Rating.loadURL.callback(req); };

		req.xhRequest.open(req.method, req.url, req.async, req.username, req.password);

		if (req.headers)
		{
			for (var name in req.headers)
				req.xhRequest.setRequestHeader(name, req.headers[name]);
		}

		req.xhRequest.send(req.postData);

		if (!req.async)
			Spry.Widget.Rating.loadURL.callback(req);
	}
	catch(e)
	{
		if (req.errorCallback)
			req.errorCallback(req);
		else
			Spry.Widget.Rating.prototype.showError("Exception caught while loading " + url + ": " + e);
		req = null;
	}

	return req;
};

Spry.Widget.Rating.loadURL.callback = function(req)
{
	if (!req || req.xhRequest.readyState != 4)
		return;
	if (req.successCallback && (req.xhRequest.status == 200 || req.xhRequest.status == 0))
		req.successCallback(req);
	else if (req.errorCallback)
		req.errorCallback(req);
};

Spry.Widget.Rating.loadURL.Request = function()
{
	var props = Spry.Widget.Rating.loadURL.Request.props;
	var numProps = props.length;

	for (var i = 0; i < numProps; i++)
		this[props[i]] = null;

	this.method = "GET";
	this.async = true;
	this.headers = {};
};

Spry.Widget.Rating.loadURL.Request.props = [ "method", "url", "async", "username", "password", "postData", "successCallback", "errorCallback", "headers", "userData", "xhRequest" ];





// SpryTooltip.js - version 0.7 - Spry Pre-Release 1.6.1

// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//   * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//   * Neither the name of Adobe Systems Incorporated nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.BrowserSniff = function()
{
	var b = navigator.appName.toString();
	var up = navigator.platform.toString();
	var ua = navigator.userAgent.toString();

	this.mozilla = this.ie = this.opera = this.safari = false;
	var re_opera = /Opera.([0-9\.]*)/i;
	var re_msie = /MSIE.([0-9\.]*)/i;
	var re_gecko = /gecko/i;
	var re_safari = /(applewebkit|safari)\/([\d\.]*)/i;
	var r = false;

	if ( (r = ua.match(re_opera))) {
		this.opera = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_msie))) {
		this.ie = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_safari))) {
		this.safari = true;
		if(parseFloat(r[2]) < 420)
			this.version = 2;
		else
			this.version = 3;		
	} else if (ua.match(re_gecko)) {
		var re_gecko_version = /rv:\s*([0-9\.]+)/i;
		r = ua.match(re_gecko_version);
		this.mozilla = true;
		this.version = parseFloat(r[1]);
	}
	this.windows = this.mac = this.linux = false;

	this.Platform = ua.match(/windows/i) ? "windows" :
					(ua.match(/linux/i) ? "linux" :
					(ua.match(/mac/i) ? "mac" :
					ua.match(/unix/i)? "unix" : "unknown"));
	this[this.Platform] = true;
	this.v = this.version;

	if (this.safari && this.mac && this.mozilla) {
		this.mozilla = false;
	}
};

Spry.is = new Spry.Widget.BrowserSniff();

Spry.Widget.Tooltip = function(tooltip_element, trigger_selector, options)
{
	options = Spry.Widget.Utils.firstValid(options, {});

	this.init(trigger_selector, tooltip_element, options);

	if (Spry.Widget.Tooltip.onloadDidFire)
		this.attachBehaviors();
	
	Spry.Widget.Tooltip.loadQueue.push(this);
};

Spry.Widget.Tooltip.prototype.init = function(trigger_element, tooltip_element, options)
{
	var Utils = Spry.Widget.Utils;
	this.triggerElements = Utils.getElementsByClassName(trigger_element);
	this.tooltipElement = Utils.getElement(tooltip_element);

	options.showDelay = parseInt(Utils.firstValid(options.showDelay, 0), 10);
	options.hideDelay = parseInt(Utils.firstValid(options.hideDelay, 0), 10);

	if (typeof this.triggerElements == 'undefined' || !(this.triggerElements.length > 0))
	{
		this.showError('The element(s) "' + trigger_element + '" do not exist in the page');
		return false;
	}
	if (typeof this.tooltipElement == 'undefined' || !this.tooltipElement)
	{
		this.showError('The element "' + tooltip_element + '" do not exists in the page');
		return false;
	}

	this.listenersAttached = false;
	this.hoverClass = "";
	this.followMouse = false;
	this.offsetX = 15;
	this.offsetY = 15;
	this.closeOnTooltipLeave = false;
	this.useEffect = false;

	Utils.setOptions(this, options);
	this.animator = null;
	for (var i =0; i < this.triggerElements.length; i++)
		if (!this.triggerElements[i].className)
			this.triggerElements[i].className = '';

	if (this.useEffect){
			switch (this.useEffect.toString().toLowerCase()){
				case 'blind': this.useEffect = 'Blind'; break;
				case 'fade': this.useEffect = 'Fade'; break;
				default:
					this.useEffect = false;
			}
	}
	
	this.visibleTooltip = false;

	// Hack for FF 3 - Safari 3: force painting of the element, in order to have the correct display
	this.tooltipElement.offsetHeight;
	// Optimisation: save browser work if display is already 'none'
	if (Spry.Widget.Utils.getStyleProperty(this.tooltipElement, 'display') != 'none')
	{
		this.tooltipElement.style.display = 'none';
	}

	if (typeof this.offsetX != 'numeric')
		this.offsetX = parseInt(this.offsetX, 10);

	if (isNaN(this.offsetX))
		this.offsetX = 0;

	if (typeof this.offsetY != 'numeric')
		this.offsetY = parseInt(this.offsetY, 10);

	if (isNaN(this.offsetY))
		this.offsetY = 0;

	this.tooltipElement.style.position = 'absolute';
	this.tooltipElement.style.top = '0px';
	this.tooltipElement.style.left = '0px';
};

Spry.Widget.Tooltip.onloadDidFire = false;
Spry.Widget.Tooltip.loadQueue = [];

Spry.Widget.Tooltip.addLoadListener = function(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);
};

Spry.Widget.Tooltip.processLoadQueue = function(handler)
{
	Spry.Widget.Tooltip.onloadDidFire = true;
	var q = Spry.Widget.Tooltip.loadQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++)
		if (!q[i].listenersAttached)
			q[i].attachBehaviors();
};

Spry.Widget.Tooltip.addLoadListener(Spry.Widget.Tooltip.processLoadQueue);

Spry.Widget.Tooltip.prototype.addClassName = function(ele, className)
{
	if (!ele || !className)
		return;
	if (ele.className.indexOf(className) == -1)
		ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.Tooltip.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className )
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.Tooltip.prototype.showTooltip = function()
{
//if (this.tooltipElement.id != 'sprytooltip1') {
	  //document.getElementById('reviewloader').style.visibility = 'hidden';
      //document.getElementById('ratings').style.visibility = 'hidden';

//}

	if (!this.visibleTooltip)
	{
		this.tooltipElement.style.visibility = 'hidden';
		this.tooltipElement.style.zIndex = '9999';
		this.tooltipElement.style.display = 'block';
	}
	Spry.Widget.Utils.putElementAt(this.tooltipElement, this.pos, {x:this.offsetX, y:this.offsetY}, true);

	if(Spry.is.ie && Spry.is.version == '6')
		this.createIframeLayer(this.tooltipElement);

	if (!this.visibleTooltip)
	{
		if (this.useEffect)
		{
			if (typeof this.showEffect == 'undefined')
				this.showEffect = new Spry.Widget.Tooltip[this.useEffect](this.tooltipElement, {from: 0, to: 1});

			this.showEffect.start();
		}
		else
			this.tooltipElement.style.visibility = 'visible';
	}
	this.visibleTooltip = true;
};
Spry.Widget.Tooltip.prototype.hideTooltip = function(quick)
{
	//if (this.tooltipElement.id != 'sprytooltip1') {
	 // document.getElementById('reviewloader').style.visibility = 'visible';
      //document.getElementById('ratings').style.visibility = 'visible';

	//}

	if (this.useEffect && !quick)
	{
			if (typeof this.hideEffect == 'undefined')
				this.hideEffect = new Spry.Widget.Tooltip[this.useEffect](this.tooltipElement, {from: 1, to: 0});

			this.hideEffect.start();
	}
	else
	{
		if (typeof this.showEffect != 'undefined')
			this.showEffect.stop();
		this.tooltipElement.style.display = 'none';
	}
	if(Spry.is.ie && Spry.is.version == '6')
		this.removeIframeLayer(this.tooltipElement);

	if (this.hoverClass && !this.hideTimer)
	{
		for (var i = 0; i < this.triggerElements.length; i++)
			this.removeClassName(this.triggerElements[i], this.hoverClass);
	}
	this.visibleTooltip = false;
};
Spry.Widget.Tooltip.prototype.displayTooltip = function(show) {
	if (this.tooltipElement)
	{
		if (this.hoverClass){
			for (var i = 0; i < this.triggerElements.length; i++)
				this.removeClassName(this.triggerElements[i], this.hoverClass);
		}
		if (show)
		{
			if (this.hideTimer)
			{
				clearInterval(this.hideTimer);
				delete(this.hideTimer);
			}

			if (this.hoverClass)
			{
				if (typeof this.triggerHighlight != 'undefined')
					this.addClassName(this.triggerHighlight, this.hoverClass);
			}
			var self = this;
			this.showTimer = setTimeout(function(){self.showTooltip()}, this.showDelay);
		}
		else
		{
			if (this.showTimer)
			{
				clearInterval(this.showTimer);
				delete(this.showTimer);
			}
			var self = this;
			this.hideTimer = setTimeout(function(){self.hideTooltip();}, this.hideDelay);
		}
	}
	this.refreshTimeout();
};
Spry.Widget.Tooltip.prototype.onMouseOverTrigger = function(e)
{
	var target = '';
	if (Spry.is.ie)
		target = e.srcElement;
	else
		target = e.target;

	var contains = Spry.Widget.Utils.contains;
	for (var i = 0; i < this.triggerElements.length; i++)
		if (contains(this.triggerElements[i], target))
		{
			target = this.triggerElements[i];
			break;
		}

	if (i == this.triggerElements.length) return;

	if (this.visibleTooltip && this.triggerHighlight && this.triggerHighlight == target)
	{
		if (this.hideTimer)
		{
			clearInterval(this.hideTimer);
			delete(this.hideTimer);
		}
		if (this.hoverClass)
		{
			if (typeof this.triggerHighlight != 'undefined')
				this.addClassName(this.triggerHighlight, this.hoverClass);
		}
		return;
	}

	var pos = Spry.Widget.Utils.getAbsoluteMousePosition(e);
	this.pos = {x: pos.x + this.offsetX, y: pos.y + this.offsetY};

	this.triggerHighlight = target;

	Spry.Widget.Tooltip.closeAll();
	this.displayTooltip(true);
};

Spry.Widget.Tooltip.prototype.onMouseMoveTrigger = function(e)
{
	var pos = Spry.Widget.Utils.getAbsoluteMousePosition(e);
	this.pos = {x: pos.x + this.offsetX, y: pos.y + this.offsetY};
	if (this.visibleTooltip)
		this.showTooltip();
};
Spry.Widget.Tooltip.prototype.onMouseOutTrigger = function(e)
{
	var target = '';
	if (Spry.is.ie)
		target = e.toElement;
	else
		target = e.relatedTarget;

	var contains = Spry.Widget.Utils.contains;
	for (var i=0; i < this.triggerElements.length; i++)
		if (contains(this.triggerElements[i], target))
			return;

	this.displayTooltip(false);
};
Spry.Widget.Tooltip.prototype.onMouseOutTooltip = function(e)
{
	var target = '';
	if (Spry.is.ie)
		target = e.toElement;
	else
		target = e.relatedTarget;

	var contains = Spry.Widget.Utils.contains;
	if (contains(this.tooltipElement, target))
		return;

	this.displayTooltip(false);
};

Spry.Widget.Tooltip.prototype.onMouseOverTooltip = function(e)
{
	if (this.hideTimer)
	{
		clearInterval(this.hideTimer);
		delete(this.hideTimer);
	}
	if (this.hoverClass)
	{
		if (typeof this.triggerHighlight != 'undefined')
			this.addClassName(this.triggerHighlight, this.hoverClass);
	}
};

Spry.Widget.Tooltip.prototype.refreshTimeout = function()
{
	if (Spry.Widget.Tooltip.refreshTimeout != null)
	{
		clearTimeout(Spry.Widget.Tooltip.refreshTimeout);
		Spry.Widget.Tooltip.refreshTimeout = null;
	}

	Spry.Widget.Tooltip.refreshTimeout = setTimeout(Spry.Widget.Tooltip.refreshAll, 100);
};

Spry.Widget.Tooltip.prototype.destroy = function()
{
	for (var k in this)
	{
		try{
				if (typeof this.k == 'object' && typeof this.k.destroy == 'function') this.k.destroy();
				delete this.k;
			}catch(err){}
	}
};

Spry.Widget.Tooltip.prototype.checkDestroyed = function()
{
// checks the parent node. If it exists, then the element is still in the DOM
	if (!this.tooltipElement || this.tooltipElement.parentNode == null)
		return true;

	return false;
};

Spry.Widget.Tooltip.prototype.attachBehaviors = function()
{
	var self = this;
	var ev = Spry.Widget.Utils.addEventListener;
	for (var i=0; i< this.triggerElements.length; i++)
	{
		ev(this.triggerElements[i], 'mouseover', function(e) {self.onMouseOverTrigger(e || event); return true;}, false);
		ev(this.triggerElements[i], 'mouseout', function(e) {self.onMouseOutTrigger(e || event); return true;}, false);

		if (this.followMouse)
			ev(this.triggerElements[i], 'mousemove', function(e) {self.onMouseMoveTrigger(e || event); return true;}, false);
	}
	if (this.closeOnTooltipLeave)
	{
		ev(this.tooltipElement, 'mouseover', function(e){self.onMouseOverTooltip(e || event); return true;}, false);
		ev(this.tooltipElement, 'mouseout', function(e){self.onMouseOutTooltip(e || event); return true;}, false);
	}
	this.listenersAttached = true;
};

// createIframeLayer for Tooltip
// creates an IFRAME underneath a tooltip element so that it will show above form controls and ActiveX
Spry.Widget.Tooltip.prototype.createIframeLayer = function(tooltip)
{
	if (typeof this.iframeLayer == 'undefined')
	{
		var layer = document.createElement('iframe');
		layer.tabIndex = '-1';
		layer.src = 'javascript:"";';
		layer.scrolling = 'no';
		layer.frameBorder = '0';
		layer.className = 'iframeTooltip';
		tooltip.parentNode.appendChild(layer);
		this.iframeLayer = layer;
	}
	this.iframeLayer.style.left = tooltip.offsetLeft + 'px';
	this.iframeLayer.style.top = tooltip.offsetTop + 'px';
	this.iframeLayer.style.width = tooltip.offsetWidth + 'px';
	this.iframeLayer.style.height = tooltip.offsetHeight + 'px';
	this.iframeLayer.style.display = 'block';

};

// removeIframeLayer for Tooltip Element
// removes an IFRAME underneath a tooltip to reveal any form controls and ActiveX
Spry.Widget.Tooltip.prototype.removeIframeLayer =  function(tooltip)
{
	if (this.iframeLayer)
		this.iframeLayer.style.display = 'none';

};

Spry.Widget.Tooltip.prototype.showError = function(msg)
{
	alert('Spry.Widget.Tooltip ERR: ' + msg);
};

Spry.Widget.Tooltip.refreshAll = function()
{
	var q = Spry.Widget.Tooltip.loadQueue;
	var qlen = q.length;

	for (var i = 0; i < qlen ; i++) 
	{
		if (q[i].checkDestroyed()) 
		{
			// the trigger element is no longer in the dom, we should remove the current widget.
			q[i].destroy();
			q.splice(i, 1);
			i--;
			qlen = q.length;
		}
	}
};

Spry.Widget.Tooltip.closeAll = function()
{
	var q = Spry.Widget.Tooltip.loadQueue;
	var qlen = q.length;

	for (var i = 0; i < qlen ; i++)
	{
		if (q[i].visibleTooltip)
			q[i].hideTooltip(true);

		if (q[i].showTimer)
			clearTimeout(q[i].showTimer);	

		if (q[i].hideTimer)
			clearTimeout(q[i].hideTimer);
	}
};

Spry.Widget.Tooltip.Animator = function(element, opts)
{
	this.timer = null;

	this.fps = 60;
	this.duration = 500;
	this.startTime = 0;

	this.transition = Spry.Widget.Tooltip.Animator.defaultTransition;

	this.onComplete = null;

	if (typeof element == 'undefined') return;
	this.element = Spry.Widget.Utils.getElement(element);

	Spry.Widget.Utils.setOptions(this, opts, true);
	this.interval = this.duration / this.fps;
};

Spry.Widget.Tooltip.Animator.defaultTransition = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); };

Spry.Widget.Tooltip.Animator.prototype.start = function()
{
	var self = this;
	this.startTime = (new Date).getTime();
	this.beforeStart();
	this.timer = setInterval(function() { self.stepAnimation(); }, this.interval);
};

Spry.Widget.Tooltip.Animator.prototype.stop = function()
{
	if (this.timer)
		clearTimeout(this.timer);

	this.timer = null;
};
Spry.Widget.Tooltip.Animator.prototype.stepAnimation = function(){};
Spry.Widget.Tooltip.Animator.prototype.beforeStart = function(){};
Spry.Widget.Tooltip.Animator.prototype.destroy = function()
{
	for (var k in this)
		try
		{
			delete this.k;
		}catch(err){}
};

Spry.Widget.Tooltip.Fade = function(element, opts)
{
	Spry.Widget.Tooltip.Animator.call(this, element, opts);
	if (Spry.is.ie)
		this.origOpacity = this.element.style.filter;
	else
		this.origOpacity = this.element.style.opacity;
};
Spry.Widget.Tooltip.Fade.prototype = new Spry.Widget.Tooltip.Animator();
Spry.Widget.Tooltip.Fade.prototype.constructor = Spry.Widget.Tooltip.Fade;

Spry.Widget.Tooltip.Fade.prototype.stepAnimation = function()
{
	var curTime = (new Date).getTime();
	var elapsedTime = curTime - this.startTime;

	var i, obj;

	if (elapsedTime >= this.duration)
	{
		this.beforeStop();
		this.stop();
		return;
	}

	var ht = this.transition(elapsedTime, this.from, this.to - this.from, this.duration);
	if (Spry.is.ie)
	{
		var filter = this.element.style.filter.replace(/alpha\s*\(\s*opacity\s*=\s*[0-9\.]{1,3}\)/, '');
		this.element.style.filter = filter + 'alpha(opacity=' + parseInt(ht * 100, 10) + ')';
	}
	else
	{
		this.element.style.opacity = ht;
	}
	this.element.style.visibility = 'visible';
	this.element.style.display = 'block';
};
Spry.Widget.Tooltip.Fade.prototype.beforeStop = function()
{
	if (this.from > this.to)
		this.element.style.display = 'none';

	if (Spry.is.mozilla)
		this.element.style.filter = this.origOpacity;
	else
		this.element.style.opacity = this.origOpacity;
};

Spry.Widget.Tooltip.Blind = function(element, opts)
{
	this.from = 0;
	this.to = 100;
	Spry.Widget.Tooltip.Animator.call(this, element, opts);
	this.element.style.visibility = 'hidden';
	this.element.style.display = 'block';
	this.origHeight = parseInt(Spry.Widget.Utils.getStyleProperty(this.element, 'height'),10);
	if (isNaN(this.origHeight))
		this.origHeight = this.element.offsetHeight;

	if (this.to == 0)
		this.from = this.origHeight;
	else
		this.to = this.origHeight;
};
Spry.Widget.Tooltip.Blind.prototype = new Spry.Widget.Tooltip.Animator();
Spry.Widget.Tooltip.Blind.prototype.constructor = Spry.Widget.Tooltip.Blind;

Spry.Widget.Tooltip.Blind.prototype.beforeStart = function()
{
	this.origOverflow = Spry.Widget.Utils.getStyleProperty(this.element, 'overflow');
	this.element.style.overflow = 'hidden';
};
Spry.Widget.Tooltip.Blind.prototype.stepAnimation = function()
{
	var curTime = (new Date).getTime();
	var elapsedTime = curTime - this.startTime;

	var i, obj;

	if (elapsedTime >= this.duration)
	{
		this.beforeStop();
		this.stop();
		return;
	}
	var ht = this.transition(elapsedTime, this.from, this.to - this.from, this.duration);
	this.element.style.height = Math.floor(ht) + 'px';
	this.element.style.visibility = 'visible';
	this.element.style.display = 'block';
};
Spry.Widget.Tooltip.Blind.prototype.beforeStop = function()
{
	this.element.style.overflow = this.origOverflow;
	if (this.from > this.to)
		this.element.style.display = 'none';
	
	this.element.style.height = this.origHeight + 'px';
};
//////////////////////////////////////////////////////////////////////
//
// Spry.Widget.Utils
//
//////////////////////////////////////////////////////////////////////

if (!Spry.Widget.Utils)	Spry.Widget.Utils = {};

Spry.Widget.Utils.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

Spry.Widget.Utils.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};

Spry.Widget.Utils.getElementsByClassName = function(sel)
{
	if (!sel.length > 0)
		return null;

	var selectors = sel.split(',');
	var el = [];

	for (var i =0; i < selectors.length; i++)
	{
		var cs = selectors[i];
		var chunk = cs.split(' ');
		var parents = [];
		parents[0] = [];
		parents[0][0] = document.body;
		for (var j = 0; j < chunk.length; j++)
		{
			var tokens = Spry.Widget.Utils.getSelectorTokens(chunk[j]);
			for (var k =0; k < parents[j].length; k++)
			{
				var childs = parents[j][k].getElementsByTagName('*');
				parents[j+1] = [];
				for (var l=0; l < childs.length; l++)
					if (Spry.Widget.Utils.hasSelector(childs[l], tokens))
						parents[j+1].push(childs[l]);
			}
		}
		if (parents[j])
		{
			for (var k = 0; k < parents[j].length; k++)
				el.push(parents[j][k]);
		}
	}
	return el;
};

Spry.Widget.Utils.firstValid = function()
{
	var ret = null;
	var a = Spry.Widget.Utils.firstValid;
	for(var i=0; i< a.arguments.length; i++)
	{
		if (typeof(a.arguments[i]) != 'undefined')
		{
			ret = a.arguments[i];
			break;
		}
	}
	return ret;
};
Spry.Widget.Utils.getSelectorTokens = function(str)
{
	str = str.replace(/\./g, ' .');
	str = str.replace(/\#/g, ' #');
	str = str.replace(/^\s+|\s+$/g,"");
	return str.split(' ');
};
Spry.Widget.Utils.hasSelector = function(el, tokens)
{
	for (var i =0; i< tokens.length; i++)
	{
		switch (tokens[i].charAt(0))
		{
			case '.':	if (!el.className || el.className.indexOf(tokens[i].substr(1)) == -1) return false; break;
			case '#': if (!el.id || el.id != tokens[i].substr(1)) return false; break;
			default: if (el.nodeName.toLowerCase != tokens[i]) return false; break;
		}
	}
	return true;
};
Spry.Widget.Utils.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler);
	}
	catch (e) {}
};

Spry.Widget.Utils.getStyleProperty = function(element, prop)
{
	var value;
	var camelized = Spry.Widget.Utils.camelize(prop);
	try
	{
		if (element.style)
			value = element.style[camelized];

		if (!value)
		{
			if (document.defaultView && document.defaultView.getComputedStyle)
			{
				var css = document.defaultView.getComputedStyle(element, null);
				value = css ? css.getPropertyValue(prop) : null;
			}
			else if (element.currentStyle) 
			{
					value = element.currentStyle[camelized];
			}
		}
	}
	catch (e) {}

	return value == 'auto' ? null : value;
};
Spry.Widget.Utils.camelize = function(str)
{
	if (str.indexOf('-') == -1)
		return str;	

	var oStringList = str.split('-');
	var isFirstEntry = true;
	var camelizedString = '';

	for(var i=0; i < oStringList.length; i++)
	{
		if(oStringList[i].length>0)
		{
			if(isFirstEntry)
			{
				camelizedString = oStringList[i];
				isFirstEntry = false;
			}
			else
			{
				var s = oStringList[i];
				camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
			}
		}
	}

	return camelizedString;
};

/**
 * Spry.Widget.Utils.getPixels
 * 	returns the value of a CSS property as Int, converting medium to 2
 * @param {DOMElement} m - elements
 * @param {String} s - 
 */
Spry.Widget.Utils.getPixels = function (m, s)
{
	var v = Spry.Widget.Utils.getStyleProperty(m, s);
	if (v == "medium") {
		v = 2;
	} else {
		v = parseInt(v, 10);
	}
	v = isNaN(v)?0:v;
	return v;
};

Spry.Widget.Utils.getAbsoluteMousePosition = function(ev)
{
	var pos = {x:0, y:0};
	if (ev.pageX)
		pos.x = ev.pageX;
	else if (ev.clientX)
		pos.x = ev.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);

	if (isNaN(pos.x)) pos.x = 0;

	if (ev.pageY)
		pos.y = ev.pageY;
	else if (ev.clientY)
		pos.y = ev.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

	if (isNaN(pos.y)) pos.y = 0;

	return pos;
};

/**
 * Spry.Widget.Utils.getBorderBox
 * 	returns a border box object (x,y,width,height) which perfectly covers the el element and its borders
 * 	the x, y are absolute coordinates measured from from the window viewport
 * 	use the box as the second parameter in Spry.Widget.Utils.setBorderBox
 * @param {DOMElement or String} el - 
 * @param {DOMDocument,optional} doc - 
 */
Spry.Widget.Utils.getBorderBox = function (el, doc)
{
	doc = doc || document;
	if (typeof el == 'string')
		el = doc.getElementById(el);

	if (!el)
		return false;

	if (el.parentNode === null || Spry.Widget.Utils.getStyleProperty(el, 'display') == 'none')
		//element must be visible to have a box
		return false;

	var ret = {x:0, y:0, width:0, height:0};
	var parent = null;
	var box;

	if (el.getBoundingClientRect) { // IE
		box = el.getBoundingClientRect();
		var scrollTop = doc.documentElement.scrollTop || doc.body.scrollTop;
		var scrollLeft = doc.documentElement.scrollLeft || doc.body.scrollLeft;
		ret.x = box.left + scrollLeft;
		ret.y = box.top + scrollTop;
		ret.width = box.right - box.left;
		ret.height = box.bottom - box.top;
	} else if (doc.getBoxObjectFor) { // gecko
		box = doc.getBoxObjectFor(el);
		ret.x = box.x;
		ret.y = box.y;
		ret.width = box.width;
		ret.height = box.height;
		var btw = Spry.Widget.Utils.getPixels(el, "border-top-width");
		var blw = Spry.Widget.Utils.getPixels(el, "border-left-width");
		ret.x -= blw;
		ret.y -= btw;
	} else { // safari/opera
		ret.x = el.offsetLeft;
		ret.y = el.offsetTop;
		ret.width = el.offsetWidth;
		ret.height = el.offsetHeight;
		parent = el.offsetParent;
		if (parent != el)
		{
			while (parent)
			{
				ret.x += parent.offsetLeft;
				ret.y += parent.offsetTop;
				parent = parent.offsetParent;
			}
		}
		var blw = Spry.Widget.Utils.getPixels(el, "border-left-width");
		var btw = Spry.Widget.Utils.getPixels(el, "border-top-width");
		ret.x -= blw;
		ret.y -= btw;
		// opera & (safari absolute) incorrectly account for body offsetTop
		var ua = navigator.userAgent.toLowerCase();
		if (Spry.is.opera || Spry.is.safari && Spry.Widget.Utils.getStyleProperty(el, 'position') == 'absolute')
			ret.y -= doc.body.offsetTop;
	}
	if (el.parentNode)
			parent = el.parentNode;
	else
		parent = null;
		
	while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
	{
		ret.x -= parent.scrollLeft;
		ret.y -= parent.scrollTop;
		if (parent.parentNode)
			parent = parent.parentNode;
		else
			parent = null;
	}
	return ret;
};

/**
 * Spry.Widget.Utils.setBorderBox
 * 	puts the element el to the location specified by box
 * @param {DOMElement} el - the element to be placed
 * @param {Object} box - hash containing the x and y coordinates where to put el
 *
 */
Spry.Widget.Utils.setBorderBox = function (el, box) {
	var pos = Spry.Widget.Utils.getBorderBox(el, el.ownerDocument);
	if (pos === false)
		return false;

	var delta = {
		x:Spry.Widget.Utils.getPixels(el, 'left'),
	 	y:Spry.Widget.Utils.getPixels(el, 'top')
	};

	var new_pos = {x:0, y:0, w:0, h:0};
	if (typeof box.x == 'number') {
		new_pos.x = box.x - pos.x + delta.x;
	}
	if (typeof box.y == 'number') {
		new_pos.y = box.y - pos.y + delta.y;
	}

	if (typeof box.x == 'number') {
		el.style.left = new_pos.x + 'px';
	}
	if (typeof box.y == 'number') {
		el.style.top = new_pos.y + 'px';
	}
	return true;
};

Spry.Widget.Utils.putElementAt = function (source, target, offset, biv)
{
	biv = Spry.Widget.Utils.firstValid(biv, true);

	var source_box = Spry.Widget.Utils.getBorderBox(source, source.ownerDocument);

	Spry.Widget.Utils.setBorderBox(source, target);
	if (biv)
		Spry.Widget.Utils.bringIntoView(source);

	return true;
};


/**
 * Spry.Widget.Utils.bringIntoView
 * 	set the position of the source element so it is completely visible in the window
 * @param {DOMElemenet} source - the element to be 
 */
Spry.Widget.Utils.bringIntoView = function (source) {
	var box = Spry.Widget.Utils.getBorderBox(source, source.ownerDocument);
	if (box === false) {
		return false;
	}

	var current = {
		x:Spry.Widget.Utils.getPixels(source, 'left'),
	 	y:Spry.Widget.Utils.getPixels(source, 'top')
	};

	var delta = {x:0, y:0};
	var offset_fix = {x:0, y:0};
	var strictm = source.ownerDocument.compatMode == "CSS1Compat";
	var doc = (Spry.is.ie && strictm || Spry.is.mozilla)?source.ownerDocument.documentElement:source.ownerDocument.body;

 	offset_fix.x = Spry.Widget.Utils.getPixels(doc, 'border-left-width');
 	offset_fix.y = Spry.Widget.Utils.getPixels(doc, 'border-top-width');

	var st = doc.scrollTop;
	var ch = self.innerHeight ? self.innerHeight : doc.clientHeight;

	var t = box.y + (Spry.is.ie?-offset_fix.y:offset_fix.y);
	var b = box.y + box.height + (Spry.is.ie?-offset_fix.y:offset_fix.y);

	if ( b - st > ch) {
		delta.y = ch - (b - st);
		if (t + delta.y < st) {
			delta.y = st-t;
		}
	} else if (t < st) {
		delta.y = st - t;
	}

	if (delta.y != 0) {
		source.style.top = (current.y + delta.y) + 'px';
	}

	var sl = doc.scrollLeft;
	var cw = doc.clientWidth;
	var l = box.x + (Spry.is.ie?-offset_fix.x:offset_fix.x);
	var r = box.x + box.width + (Spry.is.ie?-offset_fix.x:offset_fix.x);

	if ( r - sl > cw) {
		delta.x = cw - (r - sl);
		if (l + delta.x < sl) {
			delta.x = sl-l;
		}
	} else if (l < sl) {
		delta.x = sl - l;
	}

	if (delta.x != 0) {
		source.style.left = (current.x + delta.x) + 'px';
	}
};

Spry.Widget.Utils.contains = function (who, what) {
	if (typeof who.contains == 'object') {
		return what && who && (who == what || who.contains(what));
	} else {
		var el = what;
		while(el) {
			try{
				if (el == who) {
					return true;
				}
				el = el.parentNode;
			}catch(a){return false;}
		}
		return false;
	}
};

