	var oLib = new Object();
	// vertical margin between mouse pointer and window left edge
	oLib.cxWidth = 20;
	// horizontal margin between mouse pointer and window top edge
	oLib.cyHeight = 20;
	// mouse coords
	oLib.panelWidth="500px";
	oLib.cx = 0;
	oLib.cy = 0;
	// items array {fixed:integer, text:string, link: string}
	oLib.items = Array();
	oLib.drag = false;
	// clears all panels and removes them from items array
	oLib.clear = function(){
		for (i in oLib.items){
			if (oLib.items[i].panelRef){
				oLib.items[i].panelRef.hide();
				oLib.items[i].panelRef.destroy();
			}
		}
		oLib.items.length = 0;
	}
	// repositions panel according to mouse coords
	oLib.rw = function(id){
		if (oLib.drag)
		{
			return;
		}
		
		if (typeof(oLib.items[id])!="undefined") // panel created
		{
			// if it is hidden - show
			if (oLib.items[id].showing == false)
			{
				if (oLib.items[id].panelRef.show()){
					oLib.items[id].showing=true;
				}
			}
			// now reposition according to mouse coords	
			if (!oLib.items[id].fixed)
			{
				var box = oLib.getClientBox();
				var w = document.getElementById('panel'+id+'_c').offsetWidth;
				var h = document.getElementById('panel'+id+'_c').offsetHeight;
				
				var placeX = oLib.cx + oLib.cxWidth;
				var placeY = oLib.cy + oLib.cyHeight;
				
				if (placeX+w>=box.w)
				{
					placeX-=2*oLib.cxWidth+w;
				}
				if (placeX<0)
				{
					placeX=0;
				}
				
				if (placeY+h>=box.h)
				{
					placeY-=2*oLib.cyHeight+h;
				}
				if (placeY<0)
				{
					placeY=0;
				}
				
				
				oLib.items[id].panelRef.moveTo(placeX, placeY);
				//console.log(placeX+','+placeY);
				//console.log('>>  '+w+','+h);	
			}
		}
	}
	
	oLib.hidePopupWindows = function(){
	if (!event) return;
	if (event.clientX < 0 || event.clientY < 0){
	    for (i in oLib.items){
		if (typeof (oLib.items[i].panelRef)!="undefined" && oLib.items[i].fixed == false){
		    oLib.hw(i);
		}
	    }
	}
	}
	
	oLib.si = function(id, text, link, rank, title, adtype){

		if (typeof(oLib.items[id])=="undefined")
		{// create panel
		//if (oLib.isMSIE) needIframe = true;
			var p = new YAHOO.widget.Panel('panel'+id, {iframe:false, width:oLib.panelWidth, x:10, y:10,constraintoviewport:true,dragOnly:true, visible:false, draggable:true, close:true });
			p.dragEvent.subscribe(markDrag);
			
			var l = 50;
			if (title.length >l){
			    title = title.substring(0,l)+'...';
			}
			p.setHeader("<div class='tl'></div><span>"+title+"</span><div class='tr'></div>");
			
			p.setBody(text);
			
			var foot = "<table cellspacing='0' cellpadding='0' width='100%'><tr><td width='100' valign='top'> Rank: "+rank+"</td><td align='right'><a href='javascript:void(0);' onclick='readed("+id+"); window.open(oLib.items["+id+"].link)'>to article</a> | <a href='javascript:void(0);' onclick='mailMsgId="+id+"; showMailForm();'>send to friend</a></td></tr></table>";
			//foot = '';

			p.setFooter("<div class='bl'></div><span>"+foot+"</span><div class='br'></div>");
			p.render('product_layout');
			
			var cl = YAHOO.util.Dom.getElementsByClassName('container-close','span','panel'+id);
			if (cl.length){
				var hf = function(){
					oLib.items[id].fixed = false;
					oLib.hw(id);
				}
				cl[0].onclick = hf;
			}
			
			oManager.register([p]);
			oLib.items[id]={panelRef:p, fixed:false, showing:false, link:link};
			
		}else{
			oManager.bringToTop(oLib.items[id].panelRef);
		}
	}
	oLib.fw = function(id){
		if (typeof(oLib.items[id])!="undefined")
		{
			oLib.items[id].fixed = true;
		}
	}
	
	oLib.hwParams = function(id){
		if (typeof(oLib.items[id])!="undefined")
		{
			oLib.items[id].showing = false;
			oLib.items[id].fixed = false;
		}
	}

	// makes panel invisible
	oLib.hw = function(id){
		if (typeof(oLib.items[id])!="undefined" && oLib.items[id].fixed!=true)
		{
			//oLib.items[id].panelRef.hide();
			oManager.remove(oLib.items[id].panelRef);
			if (oLib.isMSIE){
				e = document.getElementById('panel'+id).getElementsByTagName('EMBED');
				//alert(e.length);
					for (var i = e.length - 1; i >= 0; i--) {
						e[i].parentNode.innerHTML = e[i].parentNode.innerHTML;
						for (var x in e[i]) {
							if (typeof e[i][x] == 'function') {
								e[i][x] = function(){};
							}
						}
					}

			}
			oLib.items[id].panelRef.destroy();
			oLib.hwParams(id);
			delete oLib.items[id];
		}
	}
	oLib.mouseMove = function (e) {
		var ev = e || window.event;
		oLib.ev = ev;
		if(oLib.isMSIE || oLib.isOpera7){
			oLib.cx=event.clientX+document.body.scrollLeft;
	  	  	oLib.cy=event.clientY+document.body.scrollTop;
		}
		if(oLib.isOpera){
			oLib.cx=event.clientX;
			oLib.cy=event.clientY;
		}
		if(oLib.isNetscape4 || oLib.isMozilla){
			oLib.cx = e.pageX;
			oLib.cy = e.pageY;
		}
		//alert(oLib.cx+','+oLib.cy);
		return false;
	}
	oLib.GoToAdsPage = function (url){
		if (url){
			wnd = window.open('http://'+location.hostname+'/adsredir.php?url='+url);
		}
	}
	oLib.browserVer = function(){
		oLib.isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
		oLib.isOpera=oLib.isOpera5=window.opera && oLib.isDOM //Opera 5+
		oLib.isOpera6=oLib.isOpera && window.print //Opera 6+
		oLib.isOpera7=oLib.isOpera && document.readyState //Opera 7+
		oLib.isMSIE=document.all && document.all.item && !oLib.isOpera //Microsoft Internet Explorer 4+
		oLib.isMSIE5=oLib.isDOM && oLib.isMSIE //MSIE 5+
		oLib.isNetscape4=document.layers //Netscape 4.*
		oLib.isMozilla=oLib.isDOM && navigator.appName=="Netscape" //Mozilla ��� Netscape 6.*		
	}
	
	oLib.getClientBox = function(id){
		var w, h;
		w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
		h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
		return {w:w, h:h};
	}
	
// FLASH STUFF
var regexp=/<object.*? id=["' ]*([^"']*).*?<\/object>/i;
var timers=Array();

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}
function PlayFlash(name){
	var fl = getFlashMovieObject(name);
	if (movieIsLoaded(fl)){
		//alert(fl.outerHTML);
		fl.Rewind();
		fl.Play();
		clearInterval(timers[name]);
	}
}

function StopFlash(name){
	var fl = getFlashMovieObject(name);
	if (movieIsLoaded(fl))
		fl.StopPlay();
}
// /FLASH STUFF

// EMAIL STUFF
function showEmailForm(id){
	var form = document.getElementById('mailForm'+id);	
	if (form){
		if (form.style.display=='none')
			form.style.display='block';
		else
			form.style.display='none';
	}
	/*var wnd = document.getElementById('panel'+id);
	var x = parseInt(wnd.style.left,10);
	var y = parseInt(wnd.style.top, 10);
	if (!isNaN(x) && !isNaN(y))
		oLib.cx = x; oLib.cy = y;
		oLib.handleMove(id);
	/**/
}

function sendToFriend(){
	var from=document.getElementById('mailform_from').value;
	var to=document.getElementById('mailform_to').value;	
	var text=document.getElementById('mailform_text').value;		

	var postData='id='+mailMsgId+'&from='+from+'&to='+to+'&text='+text;

	var clb = {
		success: function (o){
			alert(o.responseText);
		},
		faliure: function(){
			alert('Network error, unable to send notification');	
		}
	}
	YAHOO.util.Connect.asyncRequest('POST', srvName+'/rssreader/sendmessage.php', clb, postData);
}

function showMailForm(){
	YAHOO.panels.mailform.show();	
}

function clearMailForm(){
	document.getElementById('mailform_from').value='';
	document.getElementById('mailform_to').value='';
	document.getElementById('mailform_text').value='';
}

function findAndInjectGAds(){

}
// EMAIL STUFF
