var is_panel_open=0;
var drop_down_str="";

var mouse_x = 0
var mouse_y = 0

function ToggleAllCategories(cat_start,cat_end)
	{
		for(count=cat_start;count<=cat_end;count++)
			{
				if(document.getElementById("cat_"+count).style.display=='none')document.getElementById("cat_"+count).style.display='block';
				else document.getElementById("cat_"+count).style.display='none';
			}
		if(document.getElementById("cat_more").innerHTML=='more...')document.getElementById("cat_more").innerHTML='less...';
		else document.getElementById("cat_more").innerHTML='more...';
	}
function ChangeCurrentLanguage()
	{
		temp_arr=document.getElementById('language_drop_down').value.split("_");
		temp_url='http://search.bipmedia.com/set_locale.php?language='+temp_arr[0]+'&country_code='+temp_arr[1]+'&locale='+temp_arr[2]+'&back_url=http://search.bipmedia.com/news/latest/1';
		location.href=temp_url;
	}
function SetImagePageTitle(image_title)
	{
		document.getElementById('search_terms').innerHTML=image_title;	
		if(navigator.appName.indexOf('Internet Explorer')<0)document.getElementById('image_title').innerHTML=image_title;
	}
function php_urlencode(str)
	{
		str = escape(str);
		return str.replace(/[*+\/@]|%20/g,
			function (s) {
				switch (s) {
					case "*": s = "%2A"; break;
					case "+": s = "%2B"; break;
					case "/": s = "%2F"; break;
					case "@": s = "%40"; break;
					case "%20": s = "+"; break;
				}
				return s;
			}
		);
	}
function IsOldBrowser()
	{
		var browser=navigator.appName;
		var b_version=navigator.appVersion;
		var version=parseFloat(b_version);
		if ((browser=="Netscape" && version>4)||(browser=="Microsoft Internet Explorer" && b_version.indexOf('MSIE 7.0')>0)||(browser=="")||(browser=="Opera"))
	  		{
	  			return false;	
	  		}
		else
	  		{
	  			return true;
	  		}
	}

function getMouseXY(e)
	{
  		if(IE)
  			{ // grab the x-y pos.s if browser is IE
    			tempX = event.clientX + document.body.scrollLeft
    			tempY = event.clientY + document.body.scrollTop
  			}
  		else
  			{  // grab the x-y pos.s if browser is NS
    			tempX = e.pageX
    			tempY = e.pageY
  			}  
  		// catch possible negative values in NS4
  		if (tempX < 0){tempX = 0}
  		if (tempY < 0){tempY = 0}  
  		// show the position values in the form named Show
  		// in the text fields named MouseX and MouseY
  		//document.Show.MouseX.value = tempX
  		//document.Show.MouseY.value = tempY
		mouse_x=tempX;
		mouse_y=tempY;	
	}
	
function CheckEnter(e)
	{
		var characterCode; //literal character code will be stored in this variable
		if(e && e.which)
			{ //if which property of event object is supported (NN4)
				e = e
				characterCode = e.which //character code is contained in NN4's which property
			}
		else
			{
				e = event
				characterCode = e.keyCode //character code is contained in IE's keyCode property
			}
		if(characterCode == 13)
			{ //if generated character code is equal to ascii 13 (if enter key)
				//document.forms[0].submit() //submit the form
				return true
			}
		else
			{
				return false
			}
	}
function GetViewPortSize()
	{
		 var viewportwidth;
		 var viewportheight;
		 
		 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		 
		 if (typeof window.innerWidth != 'undefined')
		 {
		      viewportwidth = window.innerWidth,
		      viewportheight = window.innerHeight
		 }
		 
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		
		 else if (typeof document.documentElement != 'undefined'
		     && typeof document.documentElement.clientWidth !=
		     'undefined' && document.documentElement.clientWidth != 0)
		 {
		       viewportwidth = document.documentElement.clientWidth,
		       viewportheight = document.documentElement.clientHeight
		 }
		 
		 // older versions of IE
		 
		 else
		 {
		       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		       viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
		 return (viewportwidth+"*"+viewportheight);
	}
function PlaySong(file_name,is_parent)
	{
		if(!is_parent)
			{
				ply.sendEvent('stop');
				setTimeout('ply.sendEvent("load","'+file_name+'")',100);
				setTimeout('ply.sendEvent("play")',200);
			}
		else
			{
				parent.ply.sendEvent('stop');
				setTimeout('parent.ply.sendEvent("load","'+file_name+'")',100);
				setTimeout('parent.ply.sendEvent("play")',200);
			}
	}
function StopSong()
	{
		if(location.href.indexOf('/music')>0)ply.sendEvent('stop');
	}
function ToggleHeaderDropDowns(div_id,other_div_ids) 
	{
  		ToggleDiv(div_id);
  		
  		temp_arr=other_div_ids.split(",");
  		for(count=0;count<temp_arr.length;count++)
  			{
  				id=temp_arr[count];
  				if(document.getElementById(id))document.getElementById(id).style.display='none';
  			}
	}
	
function PopupPlayer(file_name,id,stuff) 
	{
  		window.open(file_name,id,stuff);
	}
	
function getElementLeft(Elem) 
	{
		var elem;
		if(document.getElementById) 
			{
				var elem = document.getElementById(Elem);
			} 
		else if (document.all)
			{
				var elem = document.all[Elem];
			}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) 
  			{
  				xPos += tempEl.offsetLeft;
	  			tempEl = tempEl.offsetParent;
  			}
		return xPos;
	}

function getElementTop(Elem) 
	{
		if(document.getElementById) 
			{	
				var elem = document.getElementById(Elem);
			} 
		else if (document.all) 
			{
				var elem = document.all[Elem];
			}
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) 
			{
  				yPos += tempEl.offsetTop;
	  			tempEl = tempEl.offsetParent;
  			}
		return yPos;
	}

function GetIrcInvitation(member_id)
	{
		xajax_get_irc_invitations(member_id);
	}
function ShowIrcInvitation(result)
	{
		if(result!='-1')
			{
				temp_arr=result.split("*");
				member_id=temp_arr[0];
				invitation_id=temp_arr[1];
				channel_name=temp_arr[2];
				inviter_name=temp_arr[3];
				if(confirm(inviter_name+" has just invited you to a private chat room. Click ok to accept or cancel to decline."))
					{
						xajax_set_irc_invitation_ack(member_id,invitation_id);
						clearInterval(timer_irc);
						location.href='/irc/chat/homer.bipmedia.com/'+channel_name+'/1';
					}
				else
					{
						xajax_set_irc_invitation_ack(member_id,invitation_id);
						clearInterval(timer_irc);
					}
			}
	}
	
function CreateCookie(name,value,days) 
	{
		if(days) 
			{
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

function SetSearchUrl(search_section)
	{
		search_type='';
		type_code='';
		
		if(document.getElementById('value').value==''&&search_section!='usenet')return;
		
		document.getElementById('value').value=php_urlencode(document.getElementById('value').value);
		
		if(document.getElementById('type'))
			{
				type_code=document.getElementById('type').value;
				if(type_code=='a')search_type='artist';
				else if(type_code=='t')search_type='title';
				else if(type_code=='l')search_type='album';
				else if(type_code=='y')search_type='lyrics';
				else if(type_code=='i')search_type='interactive';
				else if(type_code=='n')search_type='noninteractive';
			}
		if(search_section=='usenet')
			{
				if(document.getElementById('value').value=='')document.getElementById('search_form').action+='/all/1';
				else document.getElementById('search_form').action+='/search/server/*/group/'+document.getElementById('value').value+'/*/*/summary/1';	
				document.getElementById('search_form').submit();
			}
		else if(search_section=='finance')
			{
				document.getElementById('search_form').action+='/'+search_type+'/stocks/symbols/'+document.getElementById('value').value+'/1';	
				document.getElementById('search_form').submit();
			}
		else
			{
				if(search_type!='')document.getElementById('search_form').action+='/'+search_type;	
				document.getElementById('search_form').action+='/'+document.getElementById('value').value+'/1';
				document.getElementById('search_form').submit();		
			}
	}
function GetSearchUrl(search_section,type,value)
	{
		search_type='';
		type_code='';
		url="/"+search_section;
		if(type!='')
			{
				type_code=type;
				if(type_code=='a'&&search_section=='music')search_type='artist';
				else if(type_code=='t'&&search_section=='music')search_type='title';
				else if(type_code=='l'&&search_section=='music')search_type='album';
				else if(type_code=='y'&&search_section=='music')search_type='lyrics';
				else if(type_code=='i'&&search_section=='finance')search_type='interactive';
				else if(type_code=='n'&&search_section=='finance')search_type='noninteractive';
			}
		if(search_section=='usenet')
			{
				url+='/search/server/*/group/'+value+'/*/*/summary/1';	
			}
		else if(search_section=='finance')
			{
				url+='/'+search_type+'/stocks/symbols/'+value+'/1';	
			}
		else
			{
				if(search_type!='')url+='/'+search_type;	
				url+='/'+value+'/1';
			}
		return url;
	}
function ResizeWindow(w,h) 
	{
 		if (parseInt(navigator.appVersion)>3) 
 			{
   				if (navigator.appName=="Netscape") 
   					{
    					top.outerWidth=w;
    					top.outerHeight=h;
   					}
   				else top.resizeTo(w,h);
 			}
	}
function OnResizeWindow(offset_top,offset_left,search_page,language_alignment)
	{
		temp_arr=GetViewPortSize().split('*');
		screen_width=temp_arr[0];
		if(navigator.appName.indexOf('Microsoft')==-1)
			{
				if(document.getElementById('header_left'))document.getElementById('header_left').style.left='5px';
				
				if(document.getElementById('small_arrow'))
				{
					flag_left=(getElementLeft('small_arrow')-130);				
					if(flag_left<0)flag_left+=100;
				}
				if(document.getElementById('header_right'))document.getElementById('header_right').style.left=(screen_width)*(.6)+'px';
				if(document.getElementById('flags'))document.getElementById('flags').style.left=flag_left+'px';
				if(document.getElementById('flags'))document.getElementById('flags').style.top=(getElementTop('small_arrow')+20)+'px';
			}
		else
			{
				if(document.getElementById('header_left'))document.getElementById('header_left').style.left='15px';
				if(document.getElementById('header_right'))
					{
						document.getElementById('header_right').style.left=screen_width*.60+'px';
						if(screen_width<1200)document.getElementById('header_right').style.left=screen_width*.50+'px';
					}
				if(document.getElementById('flags'))
					{
						document.getElementById('flags').style.left=(screen_width-250)+'px';
						document.getElementById('flags').style.top='25px';	
					}
				if(document.getElementById('flags_div'))document.getElementById('flags_div').style.top='25px';
			}
			
		if(document.getElementById('search_header'))
			{
				overlay_height=document.getElementById('search_header').offsetHeight;		
				overlay_height-=offset_top;
			}
		
		is_older_browser=IsOldBrowser();
		
		if(document.getElementById('overlay'))
			{
				header_left_top=document.getElementById('header_left').style.top;
				header_right_top=document.getElementById('header_right').style.top;

				if(is_older_browser)
					{
						header_left_top=parseInt((header_left_top.replace('px',''))*1);
						header_left_top+=15;
						document.getElementById('header_left').style.top=header_left_top;
						
						header_right_top=parseInt((header_right_top.replace('px',''))*1);
						header_right_top+=15;
						document.getElementById('header_right').style.top=header_right_top;
					}
				document.getElementById('overlay').style.top=document.getElementById('header_left').style.top;
				temp_left=document.getElementById('header_left').style.left.replace('px','');
				temp_left=parseInt(temp_left)+parseInt(offset_left);
				document.getElementById('overlay').style.left=temp_left;
				document.getElementById('overlay').style.height=overlay_height+'px';
			}				
		if(is_older_browser&&document.getElementById('line_breaks'))
			{
				document.getElementById('line_breaks').innerHTML='';
				if(document.getElementById('music_options'))document.getElementById('music_options').width='90%';
				if(document.getElementById('search_section'))document.getElementById('search_section').width='80%';
			}
		else if((screen_width<1200)&&document.getElementById('music_options'))document.getElementById('music_options').width='80%';
		else if(document.getElementById('music_options'))document.getElementById('music_options').width='80%';
		
		if(is_older_browser&&document.getElementById('old_browsers'))
			{
				if(screen.width>969)document.getElementById('old_browsers').style.left=(screen.width-969-20)+'px';
				else document.getElementById('old_browsers').style.left=(969-screen.width-20)+'px';
				document.getElementById('old_browsers').style.display='block';
			}
		else
			{
				if(!is_older_browser && document.getElementById('overlay'))document.getElementById('overlay').style.display='block';					
			}
		if(search_page!='music'&&document.getElementById('search_sec_left'))document.getElementById('search_sec_left').style.width='18%';
		else if(document.getElementById('search_sec_left'))document.getElementById('search_sec_left').style.width='15%';
		
		if(document.getElementById('screen_width'))
			{
				document.getElementById('screen_width').value=screen.width;
			}
	}
function removeElement(parentDiv, childDiv)
	{		
	    if (document.getElementById(childDiv)) {     
	          var child = document.getElementById(childDiv);
	          var parent = document.getElementById(parentDiv);
	          parent.removeChild(child);
	     }
	     else {
	          return false;
	     }
	}
function AddToWishList(track_list_id)
	{
		id_list=document.getElementById(track_list_id).value.split(",");
		track_id=id_list[0];
		document.getElementById('search_music').action='/add_to_wishlist.php?id='+track_id;	
		document.getElementById('search_music').submit();
	}
function AddAlbumToCart(id1,id2)
	{
		document.getElementById(id2).checked=true;
		SelectAll(id1,id2);
		document.getElementById('search_music').target='top';
		document.getElementById('search_music').action='/shopping_cart.php';
		document.getElementById('search_music').submit();
	}
function SetHomePage()
	{
		if(navigator.appName.indexOf("Microsoft")==-1)alert('Please set your home page to the current page by doing the following Tools -> Options -> General -> Home Page.');
		else 
			{
				document.body.style.behavior='url(#default#homepage)';
				document.body.setHomePage('http://search.bipmedia.com/index.php');
			}
	}
function SetPageHeight()
	{
		if(document.getElementById('tooltip')&&navigator.appName.indexOf("Microsoft")!=-1)
			{
				document.getElementById('tooltip').style.top='32px';
				document.getElementById('tooltip').style.left='50px';
			}
		
		document.getElementById('main_sec').style.height=screen.height-(screen.height*.45)+"px";
		document.getElementById('value').focus();
		CreateCookie('size',(screen.height-(screen.height*.45))+"*"+(screen.width*.95),365);
	}
function SetSlideShowOptions()
	{
		hs.graphicsDir = '/js/slide_show/highslide/graphics/';
		hs.restoreCursor = '/js/slide_show/highslide/graphics/zoomout.cur';
		hs.captionId = 'the-caption';
		hs.outlineType = 'rounded-white';
		hs.outlineWhileAnimating = true;    
	}
function ApplyHeader()
	{
		if(is_my_apps=='no')location.href="/index.php?skin="+document.getElementById('large_image_name').value;
		else location.href="/my_apps.php?skin="+document.getElementById('large_image_name').value;
	}
function GrayoutScreen(is_grayout)
	{
		if(is_grayout)
			{
				if(document.getElementById('grayout_screen').value==1)return;
				
				document.getElementById('grayout_screen').value=1;
				
				GrayOut(true);
			}
		else
			{							
				document.getElementById('grayout_screen').value=0;
				
				GrayOut(false);
			}
	}	

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=200,left = 0,top = 0');");
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function SaveToggle(div_id)
	{
		document.getElementById("last_toggle_id").value=div_id;
	}
var timerID = 0;

function toggle(toggleId, e)
{
 if (!e) {
  e = window.event;
 }
 if (!document.getElementById) {
  return false;
 }
 var body = document.getElementById(toggleId);
 if (!body) {
  return false;
 }
 var im = toggleId + "_toggle";
 if (body.style.display == 'none') {
  body.style.display = 'block';
  if (document.images[im]) {
   document.images[im].src = "close.png";
  }
 } else {
  body.style.display = 'none';
  if (document.images[im]) {
   document.images[im].src = "open.png";
  }
 }
 if (e) {
  // Stop the event from propagating, which
  // would cause the regular HREF link to
  // be followed, ruining our hard work.
  e.cancelBubble = true;
  if (e.stopPropagation) {
   e.stopPropagation();
  }
 }
}

function DisplayNewsVideo(count,embed_url,video_image_url,width,height,is_autostart)
	{
		if(document.getElementById('videos_'+count).style.display=='none')
			{
				document.getElementById('image_'+count).src='images/minus.jpg';			
				createPlayer('p_'+count,'player_'+count, embed_url, document.getElementById('player_'+count).innerHTML,video_image_url,width,height,'','none','true');
			}
		else document.getElementById('image_'+count).src='images/plus.jpg';
		
		ToggleDiv('videos_'+count);		
	}

function ResultsBorder(table_id,td_id,is_display,color)
	{
		if(!color)color='green';
		if(is_display==1)
			{
				if(document.getElementById(table_id).style.border=='1px solid '+color)return;
				document.getElementById(table_id).style.border='1px solid '+color;
				document.getElementById(td_id).style.display='block';				
			}
		else
			{
				if(document.getElementById(table_id).style.border=='1px solid white')return;
				document.getElementById(table_id).style.border='1px solid white';
				document.getElementById(td_id).style.display='none';				
			}
	}
function SelectAll(track_ids,group_id)
	{
		is_selected=document.getElementById(group_id).checked;

		track_id_list=document.getElementById(track_ids).value.split(",");

		for(count=0;count<track_id_list.length;count++)
			{
				cb_id=track_id_list[count];
				document.getElementById(cb_id).checked=is_selected;				
			}
	}
	
function ToggleLeftSearchSection()
	{
		if(document.getElementById('left_display').style.display=='block')
			{
				document.getElementById('left_search_td').style.width='7px';
				document.getElementById('left_display').style.display='none';
				document.getElementById('middle_panel').innerHTML='<img src="/images/arr_right.jpg"/>';
			}
		else
			{
				document.getElementById('left_search_td').style.width='10%';
				document.getElementById('left_display').style.display='block';
				document.getElementById('middle_panel').innerHTML='<img src="/images/arr_left.jpg"/>';
			}
	}
	
function ToggleDiv(id)
	{
		if(document.getElementById(id).style.display=='block')
			document.getElementById(id).style.display='none';
		else
			document.getElementById(id).style.display='block';
	}
	
function SetMoreOptionsVisibility(is_visible)
	{
		if(is_visible)
			{
				document.getElementById("more_options").style.display='block';
			}
		else
			{
				document.getElementById("more_options").style.display='none';
			}
	}	
	
function NormaliseSearchBarText()
	{
		for(count=1;count<=5;count++)
			{
				document.getElementById('bar_text'+count).style.color='white';
				document.getElementById('bar_text'+count).innerHTML=document.getElementById('bar_text'+count).innerHTML.replace('<b>','');
				document.getElementById('bar_text'+count).innerHTML=document.getElementById('bar_text'+count).innerHTML.replace('<\b>','');
				document.getElementById('bar_text'+count).innerHTML=document.getElementById('bar_text'+count).innerHTML.replace('<B>','');
				document.getElementById('bar_text'+count).innerHTML=document.getElementById('bar_text'+count).innerHTML.replace('<\B>','');
			}
	}	
	
function SetColor(ele,color,is_id,id)
	{
		if(!is_id)
			{
				ele.style.color=color;
				ele.innerHTML=ele.innerHTML.replace('<b>','');
				ele.innerHTML=ele.innerHTML.replace('<\b>','');
			}
		else
			{
				NormaliseSearchBarText();
				if(id.indexOf('_text')<0)id=GetTextId(id);
				if(!document.getElementById(id))return;
				document.getElementById(id).style.color='green';
				document.getElementById(id).innerHTML='<b>'+document.getElementById(id).innerHTML+'</b>';
			}
	}	
	
function GetTextId(id)
	{
		if(id=='music')return 'bar_text1';
		else if(id=='images')return 'bar_text2';
		else if(id=='video')return 'bar_text3';
		else if(id=='games')return 'bar_text4';
		else if(id=='more')return 'bar_text5';
		else if(id=='news')return 'bar_text6';
	}	

function DisplayDiv(id,is_display)
	{
		if(is_display)document.getElementById(id).style.display='block';
		else document.getElementById(id).style.display='none';
	}	
	
function DisplaySearchBar(is_display)
	{
		is_panel_open=0;
		if(!is_display)
			{
				document.getElementById("fi_td").innerHTML=document.getElementById("fi_2").innerHTML;				
				document.getElementById('panel').innerHTML="&nbsp;";
			}
		else
			{
				document.getElementById("fi_td").innerHTML=document.getElementById("fi_3").innerHTML;
			}
		NormaliseSearchBarText();
	}		

function RemoveElement(selection)
	{
   		selection.parentNode.removeChild(selection);
	}

function GetX(obj)
	{
		var curleft = 0;
	    if(obj.offsetParent)
	        while(1) 
	        {
	          curleft += obj.offsetLeft;
	          if(!obj.offsetParent)
	            break;
	          obj = obj.offsetParent;
	        }
	    else if(obj.x)
	        curleft += obj.x;
	    return curleft;
  	}

function GetY(obj)
	{
		var curtop = 0;
	    if(obj.offsetParent)
	        while(1)
	        {
	          curtop += obj.offsetTop;
	          if(!obj.offsetParent)
	            break;
	          obj = obj.offsetParent;
	        }
	    else if(obj.y)
	        curtop += obj.y;
	    return curtop;
  	}

function SetSharedTrackDetails(title,album_art,track_id)
	{
		document.getElementById('track_name').value=title;
		document.getElementById('track_id').value=track_id;
		document.getElementById('album_art_url').value=album_art;
	}
	
function DisplayDropDown(type,id,image_id,fav_type,url,div_id)
	{		
		if(drop_down_str=="")drop_down_str=document.getElementById('drop_down_'+fav_type).innerHTML;
		
		if(document.getElementById('drop_down_'+fav_type).innerHTML.indexOf('please login')>=0)
			{
				alert(document.getElementById('login_message').value);
				if(location.href.indexOf('/widgets/')>=0)parent.location.href='/ibip_login.php?url='+Url.encode(parent.location.href);
				else parent.location.href='/login.php?url='+Url.encode(parent.location.href);
			}
		else
			{	
				if(type!='user')
					{
						image_obj=document.getElementById(image_id);
						x_co=GetX(image_obj);
						y_co=GetY(image_obj);
					}
				else
					{		
						x_co=mouse_x;
						y_co=mouse_y;
					}
				
				if(document.getElementById(div_id))y_co-=document.getElementById(div_id).scrollTop;
				
				if(drop_down_str!="")document.getElementById('drop_down_'+fav_type).innerHTML=drop_down_str;
				
				id=id.replace("'","\\'");
				document.getElementById('drop_down_'+fav_type).innerHTML=document.getElementById('drop_down_'+fav_type).innerHTML.replace(/new_id/g,id);			
				document.getElementById('drop_down_'+fav_type).innerHTML=document.getElementById('drop_down_'+fav_type).innerHTML.replace(/new_type/g,type);
				document.getElementById('drop_down_'+fav_type).style.left=x_co-50;
				document.getElementById('drop_down_'+fav_type).style.top=y_co+5;				
				document.getElementById('drop_down_'+fav_type).style.display='block';
			}
	}
	
function ToggleDisplayDropDown(type,id,image_id,fav_type,url,div_id)
	{
		if(document.getElementById('drop_down_'+fav_type).style.display=='none')DisplayDropDown(type,id,image_id,fav_type,url,div_id);
		else document.getElementById('drop_down_'+fav_type).style.display='none';
	}
	
function DisplayEmailForm(id,name,value,is_music_alert)
	{
		GrayOut(true);
		if(name!='')
			{
				document.getElementById("event_value").value=value;				
				if(is_music_alert=='0')document.getElementById("event_name").value=name;
				else 
					{
						document.getElementById("sub_category").value=name;
						document.getElementById("event_name").value='music';
					}
			}
		ToggleDiv(id);
	}
	
function HideFlash()
	{
		/* hide all flash in the page */
	    flash = document.getElementsByTagName('embed')
		for (var i = 0; i < flash.length; i++) 
			{ 
				flash[i].style.visibility = 'hidden';
	        }
	}

function ShowFlash()
	{
		/* show all flash */
		flash = document.getElementsByTagName('embed')
		for (var i = 0; i < flash.length; i++) 
        	{ 
				flash[i].style.visibility = 'visible';
        	}
	}


function GrayOut(vis, options) 
	{
	  // Pass true to gray out screen, false to ungray
	  // options are optional.  This is a JSON object with the following (optional) properties
	  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	  // in any order.  Pass only the properties you need to set.
	  if(vis)HideFlash();
	  else ShowFlash();
	  
	  var options = options || {}; 
	  var zindex = options.zindex || 50;
	  var opacity = options.opacity || 70;
	  var opaque = (opacity / 100);
	  var bgcolor = options.bgcolor || '#000000';
	  var dark=document.getElementById('darkenScreenObject');
	  if (!dark) {
	    // The dark layer doesn't exist, it's never been created.  So we'll
	    // create it here and apply some basic styles.
	    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
	    var tbody = document.getElementsByTagName("body")[0];
	    var tnode = document.createElement('div');           // Create the layer.
	        tnode.style.position='absolute';                 // Position absolutely
	        tnode.style.top='0px';                           // In the top
	        tnode.style.left='0px';                          // Left corner of the page
	        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
	        tnode.style.display='none';                      // Start out Hidden
	        tnode.id='darkenScreenObject';                   // Name it so we can find it later
	    tbody.appendChild(tnode);                            // Add it to the web page
	    dark=document.getElementById('darkenScreenObject');  // Get the object.
	  }
	  if (vis) {
	    // Calculate the page width and height 
	    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
	        var pageWidth = document.body.scrollWidth+'px';
	        var pageHeight = document.body.scrollHeight+'px';
	    } else if( document.body.offsetWidth ) {
	      var pageWidth = document.body.offsetWidth+'px';
	      var pageHeight = document.body.offsetHeight+'px';
	    } else {
	       var pageWidth='100%';
	       var pageHeight='100%';
	    }   
	    pageWidth=screen.width+'px';
	    pageHeight=screen.height+'px';
	    //set the shader to cover the entire page and make it visible.
	    dark.style.opacity=opaque;                      
	    dark.style.MozOpacity=opaque;                   
	    dark.style.filter='alpha(opacity='+opacity+')'; 
	    dark.style.zIndex=zindex;        
	    dark.style.backgroundColor=bgcolor;  
	    dark.style.width= pageWidth;
	    dark.style.height= pageHeight;
	    dark.style.display='block';                          
	  } else {
	     dark.style.display='none';
  }
}

function dragOBJ(d,e) {

    function drag(e) { if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); } }

    var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;

    document.onmousemove=drag; document.onmouseup=function(){ stop=1; document.onmousemove=''; document.onmouseup=''; };

}

function Typewriter(sName,div_name)
	{	// PROPERTIES
		this.counter = 0;
		this.name = sName;
		this.text = "";
		this.timer_object="";
		this.text_length=0;
		this.speed = 50; // in milliseconds
		
		// METHODS
		this.addText = AddText;
		this.next = Next;
		this.setSpeed = SetSpeed;
		this.write = Write;
		
		// FUNCTIONS
		function AddText(s)
		{	this.text = s
		}
		function Next()
		{	
			document.getElementById(div_name).innerHTML = this.text.substr(0, this.counter++);		
			if(this.text_length==this.counter)clearInterval(this.timer_object);
		}
		function SetSpeed(iSpeed)
		{	this.speed = iSpeed;
		}
		function Write()
		{	
			this.text_length=this.text.length;
			this.timer_object=setInterval(this.name+".next()",this.speed);
		}
	}
	
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}