/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var a,b,c,ee,d;
var ie5=document.all && !window.opera
var ns6=document.getElementById

function mouse(e)
{
	xx=ie5? event.clientX : e.clientX
	yy=ie5? event.clientY : e.clientY
}

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="delayhidemenu()"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenudelay(e, which, optWidth, nr){
	a=e; b=which; c=optWidth; d=nr;
	clearhidemenu();
	showtimer=setTimeout('showmenu()',500);
} 
function showmenudelayPict(e, which, optWidth, nr){
	a=e; b=which; c=optWidth; d=nr;
	clearhidemenu();
	showtimer=setTimeout('showmenuPict()',500);
} 

function showmenudelayPhoto(e, which, optWidth, nr){
	a=e; b=which; c=optWidth; d=nr;
	clearhidemenu();
	showtimer=setTimeout('showmenuPhoto()',100);
} 

function showmenu(){
	if (window.showtimer)
		clearTimeout(showtimer);
	e=a;which=b; optWidth=c;
	if (!document.all&&!document.getElementById)
		return
	if (typeof(which['reactStr']) == 'undefined')
		which['reactStr'] = '';
	clearhidemenu()
	menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
	
	if(which['concierge']=='1') {concierge=true;} else {concierge=false;}
	if (!which['media_type']) {which['media_type'] = 'photo';}
	menu='';
	menu+='<div>';
	menu+='<table border=0 cellpadding=0 cellspacing=0><tr><td width="7px"><img src="images/beavel/c_left1.png" width="7px" height="7px"></td><td class="t_top"></td><td><img src="images/beavel/c_right1.png" width="7px" height="7px"></td></tr>';
	menu+='<tr><td class="t_left"  width="7px"></td><td>';
	//Main table
	menu+='<table border=0 class="t2">';
	//Name
	menu+='<tr><td colspan="2" style=""><table><tr>';
	if(which['photographer']=='1') menu+='<td><img src="i/ico_red_photogr.gif"></td>';//Photographer
	if(which['canViewPortfolio']){
		if (which['auth']=='1')
			menu+='<td align="left" width="100%" style="padding-left:5px;"><a href="portfolio.php?view='+which['profile_id']+'"><font class="f1">'+which['name']+'</font></a></td><td align="right"><font color="red" style="font-size:16px;"><b style="cursor:pointer;" onclick="hidemenu();">x</b></font></td></tr></table></td></tr>';
		else
			menu+='<td align="left" width="100%" style="padding-left:5px;"><a href="#" onclick="myAlert2.open();return false;"><font class="f1">'+which['name']+'</font></a></td><td align="right"><font color="red" style="font-size:16px;"><b style="cursor:pointer;" onclick="hidemenu();">x</b></font></td></tr></table></td></tr>';
	} else {
		menu+='<td align="left" width="100%" style="padding-left:5px;"><font class="f1">'+which['name']+'</font></td><td align="right"><font color="red" style="font-size:16px;"><b style="cursor:pointer;" onclick="hidemenu();">x</b></font></td></tr></table></td></tr>';
	}
	
	menu+='<tr><td valign="top" style="padding-left:5px;padding-bottom:5px;" nowrap><font class="f22">';
	//left side
	if(!concierge && which['cty']!=', ') menu+=which['cty']+'<br>';
	menu+='</font><div  style="padding-top:4px;"><font class="f2">';
	if(which['photographer']!='1' && !concierge) menu+='<font color="#999999">Age:</font> '+which['age']+'<br>';
	if(which['photographer']!='1' && !concierge) menu+='<font color="#999999">Height:</font> '+which['height']+'<br>';
	if(which['photographer']!='1' && !concierge) menu+='<font color="#999999">Weight:</font> '+which['weight']+'<br>';
	if(!concierge) menu+='<font color="#999999">Joined:</font> '+which['joined']+'<br>';
	//Rate
	if (typeof(which['showVoting']) == 'undefined')
		which['showVoting'] = 1;
	if (which['showVoting'] == 1) {
		if(!concierge){
			if(which['auth']=='1'){
				var is_blocked = 0;
				var blocked_msg = '';
				if (which['isSetIgnoreToMe']) {
					is_blocked = 1;
					blocked_msg = 'This member blocked you';
				}
				if (which['isISetIgnoreToUser']) {
					is_blocked = 2;
					blocked_msg = 'You blocked this member';
				}
				if(which['canVoteForPhoto'] && !is_blocked){
					if(which['new_rate']){
						menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1">';
						for(x=0; x<=4; x++){
							menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'">';
						}
						menu+='</td></tr>';
						menu+='<tr><td align="left"><font class="f4">Your vote: '+(which['my_rate']/2)+'</font></td></tr>';
						menu+='</table>';
					} else {
						menu+='<table cellpadding=0 cellspacing=0 border=0 align="left"><tr><td  class="td1"><span id="'+which['uniqid']+'_'+which['media_type']+'_rate_bar_'+which['pict_id']+'" onmouseout="restoreRateBar('+which['pict_id']+',0,\''+which['uniqid']+'\',\''+which['media_type']+'\');" rating="'+which['rate_avg']+'">';
						for(x=0; x<=4; x++){
							menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" id="'+which['uniqid']+'_'+which['media_type']+'_star_'+which['pict_id']+'_'+x+'" onmousemove="showStar('+which['pict_id']+','+x+', \''+which['uniqid']+'\', event,\''+which['media_type']+'\')" onClick="'+which['reactStr']+' setRate('+which['pict_id']+','+x+', 0, event,\''+which['media_type']+'\'); return false;" style="cursor:pointer">';
						}
						menu+='</span></td></tr>';
						menu+='<tr><td align="left" nowrap><font class="f4"><a name="rating_'+which['media_type']+'_'+which['pict_id']+'" id="'+which['uniqid']+'"></a><span id="'+which['uniqid']+'_'+which['media_type']+'_sp_'+which['pict_id']+'">Rate this '+which['media_type']+'</span></font></td></tr>';
						menu+='</table>';
					}
				} else {
					menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1">';
					for(x=0; x<=4; x++){
						menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" '+(is_blocked && !which['my_rate'] ? 'alt="'+blocked_msg+'" title="'+blocked_msg+'"' : '')+'>';
					}
					menu+='</td></tr>';
					menu+='<tr><td align="left"><font class="f4">';
					if(which['my_rate']) menu+='Your vote: '+(which['my_rate']/2);
					menu+='</font></td></tr>';
					menu+='</table>';
				}
			} else {
				menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1"><span id="'+which['uniqid']+'_'+which['media_type']+'_rate_bar_'+which['pict_id']+'" onmouseout="restoreRateBar('+which['pict_id']+',0,\''+which['uniqid']+'\',\''+which['media_type']+'\');" rating="'+which['rate_avg']+'">';
				for(x=0; x<=4; x++){
					menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" id="'+which['uniqid']+'_'+which['media_type']+'_star_'+which['pict_id']+'_'+x+'" onmousemove="showStar('+which['pict_id']+','+x+', \''+which['uniqid']+'\', event, \''+which['media_type']+'\')" onclick="myAlert2.open(\'\'); return false;" style="cursor:pointer">';
				}
				menu+='</span></td></tr>';
				menu+='<tr><td align="left" nowrap><font class="f4"><a name="rating_'+which['media_type']+'_'+which['pict_id']+'" id="'+which['uniqid']+'"></a><span id="'+which['uniqid']+'_'+which['media_type']+'_sp_'+which['pict_id']+'">Rate this '+which['media_type']+'</span></font></td></tr>';
				menu+='</table>';
			}
		}
	}
	
	//Menu - right side
	menu+='</td><td valign="top" style="padding-left:10px;" align="right" width="100%">';
	menu+='<table align="right" border="0">';
	if((which['media_type']=='video' || which['media_type']=='audio') && which['linkHTML']) {
		menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left">'+which['linkHTML']+'<a style="cursor:pointer">Play '+which['media_type'].substr(0, 1).toUpperCase() + which['media_type'].substr(1)+'</a></span></td></tr>';
	}
	if(which['auth']=='1'){
		if(which['canViewPhoto'] && !concierge) {
			menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="openWindowScroll(\'norw/view_image.php?id='+which['pict_id']+'&code='+which['photo_code']+'\', 670, 670); return false;">View Photo</a></td></tr>';
		}
		if(which['canViewPortfolio'] && !concierge) menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a href="portfolio.php?view='+which['profile_id']+'">View Portfolio</a></td></tr>';
		if(which['canSendMessage']) {
			if(which['media_type']=='video' || which['media_type']=='audio'){
				menu+='<tr><td align="center"><img src="i/popup_icons/send.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="openWindow(\'norw/mediaplay.php?type='+which['media_type']+'&id='+which['pict_id']+'&code='+which['media_code']+'&action=message\', 670, 670); return false;">Send a Message</a></td></tr>';
			} else {
				menu+='<tr><td align="center"><img src="i/popup_icons/send.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="openWindow(\'norw/view_image.php?id='+which['pict_id']+'&code='+which['photo_code']+'&action=message\', 670, 670); return false;">Send a Message</a></td></tr>';
			}
		}
		if(which['canAddToContacts']) menu+='<tr><td align="center"><img src="i/popup_icons/add_to_cont.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onClick="hidemenu();myAlert1.open(\''+which['img1']+'\', \'inviteMember('+which['profile_id']+');\');">Add to Contacts</a></td></tr>';
		if(which['canAddPhotoToFavorites']) {
			menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="hidemenu(); myAlert1.open(\''+which['img2']+'\',\'addFav('+which['pict_id']+','+which['profile_id']+',\\\''+which['media_type']+'\\\');\');return false;">Add to Favorites</a></td></tr>';
		} else {
			if(which['canRemovePhotoFromFavorites']) {
				menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="remFav('+which['pict_id']+','+which['profile_id']+',\''+which['media_type']+'\'); return false;">Remove from Favorites</a></td></tr>';
			}
		}
		if(!concierge && which['canSendMessage']) {
			if(which['media_type']=='video' || which['media_type']=='audio'){
				menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="openWindow(\'norw/mediaplay.php?type='+which['media_type']+'&id='+which['pict_id']+'&code='+which['media_code']+'\', 670, 670); return false;">Add a Comment</a></td></tr>';
			} else {
				menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="openWindow(\'norw/view_image.php?id='+which['pict_id']+'&code='+which['photo_code']+'\', 670, 670); return false;">Add a Comment</a></td></tr>';
			}
		}
		if(false && which['canBlockUser']) menu+='<tr><td align="center"><img src="i/popup_icons/block.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onClick="myAlert.open(\'Block this member?\', \'blockMember('+which['profile_id']+');\');">Block Member</a></td></tr>';
	} else {
		if(which['canViewPhoto'] && !concierge) {
			menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="myAlert2.open();return false;">View Photo</a></td></tr>';
		}
		if(which['canViewPortfolio']) {
			menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open();return false;">View Portfolio</a></td></tr>';
		}
		menu+='<tr><td align="center"><img src="i/popup_icons/send.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Send a Message</a></td></tr>';
		if(which['photographer']!='1' && which['agent']!='1') menu+='<tr><td align="center"><img src="i/popup_icons/add_to_cont.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Add to Contacts</a></td></tr>';
		menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Add to Favorites</a></td></tr>';
		menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Add a Comment</a></td></tr>';
		menu+='';
	}
	//Footer
	menu+='</font></div>';
	menu+='</font></table>';
	menu+='</td></tr></table>';

	// in acting project description
	if (which['access_level'] == 4) {
		menu+='<table width="100%" bgcolor="#111111" cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1">';
		menu+='<span style="color:#999999"><b>Project:</b></span> <span style="color:white"><u>'+which['comment']+'</u></span><br>';
		menu+='<div style="width:230px;"><span style="color:#999999"><b>Description:</b></span> <span style="color:white">'+which['descr']+'</span></div>';
		menu+='</td></tr></table>';
	}
	//
	
	menu+='</td><td class="t_right"></td></tr>';
	menu+='<tr><td width="7px"><img src="images/beavel/cb_left1.png" width="7px" height="7px"></td><td  class="t_bottom"></td><td><img src="images/beavel/cb_right1.png" width="7px" height="7px"></td></tr></table>';
	
	menu+='</div>';
	
	menuobj.innerHTML=menu;
	if(!ie5) menuobj.style.width=defaultMenuWidth
	menuobj.contentwidth=menuobj.offsetWidth
	menuobj.contentheight=menuobj.offsetHeight
	
	eventX=xx
	eventY=yy
	
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
	var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<menuobj.contentwidth)
	//move the horizontal position of the menu to the left by it's width
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
	else
	//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
		
	//same concept with the vertical position
	if (bottomedge<menuobj.contentheight)
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
	else
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY+"px" : window.pageYOffset+eventY+"px"
		
	menuobj.style.visibility="visible"

	if (document.createElement) tooltip.d();
	
	return false
}



function showmenuPict(){
	if (window.showtimer)
		clearTimeout(showtimer);
	e=a;which=b; optWidth=c;
	if (!document.all&&!document.getElementById)
		return
	if (typeof(which['reactStr']) == 'undefined')
		which['reactStr'] = '';
	clearhidemenu()
	menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
	
	if(which['concierge']=='1') {concierge=true;} else {concierge=false;}
	if (!which['media_type']) {which['media_type'] = 'photo';}
	menu='';
	menu+='<div>';
	menu+='<table border=0 cellpadding=0 cellspacing=0><tr><td width="7px"><img src="images/beavel/c_left1.png" width="7px" height="7px"></td><td class="t_top"></td><td><img src="images/beavel/c_right1.png" width="7px" height="7px"></td></tr>';
	menu+='<tr><td class="t_left"  width="7px"></td><td>';
	//Main table
	menu+='<table border=0 class="t2">';
	//Name
	menu+='<tr><td colspan="2" style=""><table border=0 width="120px"><tr>';
	menu+='<td align="left" width="100%" style="padding-left:4px;"><font class="photo_name">'+which['comment']+'</font></td></tr></table></td></tr>';
	
	menu+='<tr><td valign="top" style="padding-left:5px;padding-bottom:0px;" nowrap><font class="f22">';
	//left side
	menu+=which['ph_category']+'<br>';
	menu+='<div style="padding-top:10px;"><font class="photo_views">'+which['shown']+' Views';
	if(typeof(hideRating) == 'undefined')
		menu+='| '+which['rate_cnt']+' Ratings</font></div><br>';
	menu+='</font><div  style="padding-top:0px;"><font class="f2">';
	//Menu - right side
	menu+='</td></tr>';
	menu+='<tr><td valign="top"  align="left" width="100%">';
	menu+='<table align="left" border="0">';
	if(which['auth']=='1'){
		if(which['canViewPhoto'] && !concierge) {
			menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="openWindowScroll(\'norw/view_image.php?id='+which['pict_id']+'&code='+which['photo_code']+'\', 670, 670); return false;">View Photo</a></td></tr>';
		}
		if(which['canViewMedia'] && !concierge) {
			menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a style="cursor:pointer;" onclick="'+which['media_link']+'">View '+which['media_type'].substr(0, 1).toUpperCase() + which['media_type'].substr(1)+'</a></td></tr>';
		}
		if(which['canAddPhotoToFavorites']) {
			menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="hidemenu(); myAlert1.open(\''+which['img2']+'\',\'addFav('+which['pict_id']+','+which['profile_id']+',\\\''+which['media_type']+'\\\');\');return false;">Add to Favorites</a></td></tr>';
		} else {
			if(which['canRemovePhotoFromFavorites']) {
				menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="remFav('+which['pict_id']+','+which['profile_id']+',\''+which['media_type']+'\'); return false;">Remove from Favorites</a></td></tr>';
			}
		}
		if(!concierge && which['canSendMessage']) {
			if(which['media_type']=='video' || which['media_type']=='audio'){
				menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="openWindow(\'norw/mediaplay.php?type='+which['media_type']+'&id='+which['pict_id']+'&code='+which['media_code']+'\', 670, 670); return false;">Add a Comment</a></td></tr>';
			} else {
				menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="javascript: void(0);" onclick="openWindow(\'norw/view_image.php?id='+which['pict_id']+'&code='+which['photo_code']+'\', 670, 670); return false;">Add a Comment</a></td></tr>';
			}
		}
	} else {
		menu+='<tr><td align="center"><img src="i/popup_icons/view.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">View '+which['media_type'].substr(0, 1).toUpperCase() + which['media_type'].substr(1)+'</a></td></tr>';
		menu+='<tr><td align="center"><img src="i/popup_icons/favorites.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Add to Favorites</a></td></tr>';
		menu+='<tr><td align="center"><img src="i/popup_icons/comment.gif"></td><td nowrap align="left"><a href="#" onclick="myAlert2.open(\'\'); return false;">Add a Comment</a></td></tr>';
		menu+='';
	}
	//Footer
	menu+='</font></div>';
	menu+='</font></table>';
	menu+='</td></tr><tr><td style="padding-left:5px;padding-top:5px;">';

	//Rate
	if (which['showVoting'] == 1) {
		if(!concierge){
			if(which['auth']=='1'){
				var is_blocked = 0;
				var blocked_msg = '';
				if (which['isSetIgnoreToMe']) {
					is_blocked = 1;
					blocked_msg = 'This member blocked you';
				}
				if (which['isISetIgnoreToUser']) {
					is_blocked = 2;
					blocked_msg = 'You blocked this member';
				}
				
				if(which['canVoteForPhoto'] && !is_blocked){
					if(which['new_rate']){
						menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1">';
						for(x=0; x<=4; x++){
							menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'">';
						}
						menu+='</td></tr>';
						menu+='<tr><td align="left"><font class="f4">Your vote: '+(which['my_rate']/2)+'</font></td></tr>';
						menu+='</table>';
					} else {
						menu+='<table cellpadding=0 cellspacing=0 border=0 align="left"><tr><td  class="td1"><span id="'+which['uniqid']+'_'+which['media_type']+'_rate_bar_'+which['pict_id']+'" onmouseout="restoreRateBar('+which['pict_id']+',0,\''+which['uniqid']+'\',\''+which['media_type']+'\');" rating="'+which['rate_avg']+'">';
						for(x=0; x<=4; x++){
							menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" id="'+which['uniqid']+'_'+which['media_type']+'_star_'+which['pict_id']+'_'+x+'" onmousemove="showStar('+which['pict_id']+','+x+', \''+which['uniqid']+'\', event,\''+which['media_type']+'\')" onClick="'+which['reactStr']+' setRate('+which['pict_id']+','+x+', 0, event,\''+which['media_type']+'\'); return false;" style="cursor:pointer">';
						}
						menu+='</span></td></tr>';
						menu+='<tr><td align="left" nowrap><font class="f4"><a name="rating_'+which['media_type']+'_'+which['pict_id']+'" id="'+which['uniqid']+'"></a><span id="'+which['uniqid']+'_'+which['media_type']+'_sp_'+which['pict_id']+'">Rate this '+which['media_type']+'</span></font></td></tr>';
						menu+='</table>';
					}
				} else {
					menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1">';
					for(x=0; x<=4; x++){
						menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" '+(is_blocked && !which['my_rate'] ? 'alt="'+blocked_msg+'" title="'+blocked_msg+'"' : '')+'>';
					}
					menu+='</td></tr>';
					menu+='<tr><td align="left"><font class="f4">';
					if(which['my_rate']) menu+='Your vote: '+(which['my_rate']/2);
					menu+='</font></td></tr>';
					menu+='</table>';
				}
			} else {
				menu+='<table  cellpadding=0 cellspacing=0 border=0 align="left"><tr><td class="td1"><span id="'+which['uniqid']+'_'+which['media_type']+'_rate_bar_'+which['pict_id']+'" onmouseout="restoreRateBar('+which['pict_id']+',0,\''+which['uniqid']+'\',\''+which['media_type']+'\');" rating="'+which['rate_avg']+'">';
				for(x=0; x<=4; x++){
					menu+='<img src="'+getStarSrc(which['rate_avg'], x)+'" id="'+which['uniqid']+'_'+which['media_type']+'_star_'+which['pict_id']+'_'+x+'" onmousemove="showStar('+which['pict_id']+','+x+', \''+which['uniqid']+'\', event,\''+which['media_type']+'\')" onclick="myAlert2.open(\'\'); return false;" style="cursor:pointer">';
				}
				menu+='</span></td></tr>';
				menu+='<tr><td align="left" nowrap><font class="f4"><a name="rating_'+which['media_type']+'_'+which['pict_id']+'" id="'+which['uniqid']+'"></a><span id="'+which['uniqid']+'_'+which['media_type']+'_sp_'+which['pict_id']+'">Rate this '+which['media_type']+'</span></font></td></tr>';
				menu+='</table>';
			}
		}
	}
	
	menu+='</td></tr>';
	menu+='</table>';
	
	menu+='</td><td class="t_right"></td></tr>';
	menu+='<tr><td width="7px"><img src="images/beavel/cb_left1.png" width="7px" height="7px"></td><td  class="t_bottom"></td><td><img src="images/beavel/cb_right1.png" width="7px" height="7px"></td></tr></table>';
	
	menu+='</div>';
	
	menuobj.innerHTML=menu;
	if(!ie5) menuobj.style.width=defaultMenuWidth
	menuobj.contentwidth=menuobj.offsetWidth
	menuobj.contentheight=menuobj.offsetHeight
	
	eventX=xx
	eventY=yy
	
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
	var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<menuobj.contentwidth)
	//move the horizontal position of the menu to the left by it's width
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
	else
	//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
		
	//same concept with the vertical position
	if (bottomedge<menuobj.contentheight)
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
	else
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY+"px" : window.pageYOffset+eventY+"px"
		
	menuobj.style.visibility="visible"
	return false
}



function showmenuPhoto(){
	if (window.showtimer)
		clearTimeout(showtimer);
	e=a;which=b; optWidth=c;
	if (!document.all&&!document.getElementById)
		return
	clearhidemenu()
	menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
	
	menu='';
	menu+='<div>';
	menu+='<table border=0 cellpadding=0 cellspacing=0><tr><td width="7px"><img src="images/beavel/c_left1.png" width="7px" height="7px"></td><td class="t_top"></td><td><img src="images/beavel/c_right1.png" width="7px" height="7px"></td></tr>';
	menu+='<tr><td class="t_left"  width="7px"></td><td>';
	//Main table
	menu+='<table border=0 class="t2">';
	//Name
	menu+='<tr><td colspan="2" style=""><table border=0 width="120px"><tr>';
	menu+='<td align="center" width="100%" style="padding:0px;">'+which['url']+'</td></tr></table></td></tr>';
	

	menu+='</table>';
	
	menu+='</td><td class="t_right"></td></tr>';
	menu+='<tr><td width="7px"><img src="images/beavel/cb_left1.png" width="7px" height="7px"></td><td  class="t_bottom"></td><td><img src="images/beavel/cb_right1.png" width="7px" height="7px"></td></tr></table>';
	
	menu+='</div>';
	
	menuobj.innerHTML=menu;
//	menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
	if(!ie5) menuobj.style.width=defaultMenuWidth
	menuobj.contentwidth=menuobj.offsetWidth
	menuobj.contentheight=menuobj.offsetHeight
	
	eventX=xx
	eventY=yy
	
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
	var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<menuobj.contentwidth)
	//move the horizontal position of the menu to the left by it's width
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
	else
	//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
		
	//same concept with the vertical position
	if (bottomedge<menuobj.contentheight)
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
	else
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY+"px" : window.pageYOffset+eventY+"px"
		
	menuobj.style.visibility="visible"
	return false
}



function contains_ns6(a, b) {
	//Determines if 1 element in contained in another- by Brainjar.com
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function saveInnerHtml(rate_avg,rate_cnt,my_rate){
	if (window.menuobj){
		b['rate_avg']=rate_avg;
		b['rate_cnt']=rate_cnt;
		b['my_rate']=my_rate;
		b['new_rate']=1;
		b['stars']=Math.round(b['rate_avg'])-1;
	}
}

function hidemenu(){
	if (window.menuobj)
		menuobj.style.visibility="hidden";
}


function dynamichide(e){
	if (ie5&&!menuobj.contains(e.toElement))
	hidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	hidemenu()
}

function delayhidemenu(){
	clearTimeout(showtimer);
	delayhide=setTimeout("hidemenu()",800)
}

function clearhidemenu(){
	if (window.delayhide)
		clearTimeout(delayhide)
}

//if (ie5||ns6)
//document.onclick=hidemenu


//Stars photo rating
var rate_timer = new Array();
var saving_rating = 0;
var saving_profile = 0;

function getStarSrc(rating, i) {
	path = 'i/popup_icons/';
	stars = parseInt(rating/2);
	if (i < stars) return path+'star.gif';
	if (i == stars && (diff = (rating/2) - stars) > 0) {
		if (diff < 0.5) {return path+'star_025.gif';}
		else if (diff < 0.75) {return path+'star_05.gif';}
		else {return path+'star_075.gif';}
	}
	return path+'star1.gif';
}

function restoreRateBar(id, st, pr, type) {
	prefix = pr+'_';
	if (st) {
		try {
			prev_rating = document.getElementById(prefix+type+'_rate_bar_'+id).getAttribute('rating');
			for(i=0; i<=4; i++){
				a = document.getElementById(prefix+type+'_star_' + id + '_'+i);
				a.src = getStarSrc(prev_rating, i);
			}
			document.getElementById(prefix+type+'_sp_'+id).innerHTML = 'Rate this '+type;
		} catch(e) {}
	}
	else {
		if (rate_timer[prefix+type+'_'+id]) {
			clearTimeout(rate_timer[prefix+type+'_'+id]);
		}
		if (document.getElementById(prefix+type+'_rate_bar_'+id).getAttribute('rating') == null) {
			return;
		}
		rate_timer[prefix+type+'_'+id] = setTimeout('restoreRateBar('+id+', 1, \''+pr+'\',"'+type+'")', 1000);
	}
}

function clearRating(id){
	rr=document.getElementById('star_'+id+'_0').style;
	if(rr=='') return 1;
	for(x=0; x<=4; x++){
		document.getElementById('star_'+id+'_'+x).src='i/popup_icons/star1.gif';
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function getPosX(e) {
	if (e.offsetX != null) {
		pos_x = e.offsetX;
	}
	else {
		var pos = findPos(e.currentTarget);
		pos_x = e.pageX - pos[0];
	}
	return pos_x;
}

function showStar(id,n,pr,e,type){
	if (saving_rating == id) return 1;
	pos_x = getPosX(e);
	prefix = pr+'_';
	var rate_help = new Array('Poor','Not Bad','Looks good','Star Quality','Awesome');
	if (type == 'audio') {
		rate_help = new Array('Poor','Not Bad','Sounds good','Star Quality','Awesome');
	}
	if (type == 'blog') {
		rate_help = new Array('Poor','Not Bad','Looks good','Very Cool','Awesome');
	}
	for(x=0; x<=n; x++){
		if (x == n && pos_x < 8) {
			last_star_img = 'star_05.gif';
		}
		else {
			last_star_img = 'star.gif';
		}
		document.getElementById(prefix+type+'_star_'+id+'_'+x).src='i/popup_icons/'+last_star_img;
	}
	for(x=n+1; x<=4; x++){
		document.getElementById(prefix+type+'_star_'+id+'_'+x).src='i/popup_icons/star1.gif';
	}
	if (rate_timer[prefix+type+'_'+id]) {
		clearTimeout(rate_timer[prefix+type+'_'+id]);
	}
	document.getElementById(prefix+type+'_sp_'+id).innerHTML = rate_help[n];
}

function setRate(id,n,profile,e,type){
	if (saving_rating == id) return 1;
	saving_rating = id;
	saving_profile = parseInt(profile);
	pos_x = getPosX(e);
	my_rate= 2*(n+1);
	if (pos_x < 8) {
		my_rate = my_rate - 1;
	}
	ratePhoto(id,my_rate,type);
}