/*
Script: data_rating.js
	Contains <DataRating>

Author:
	Alan Roemen

Class: DataRating
	A blog rating system

Options:
	timeout: 6,
	baseURL : Page location. Default: false
	scriptName: 'data_rating',
	ajaxURL: '/enewsletters.php'
*/
var DataRating=new Class({options:{timeout:6,baseURL:false,scriptName:"data_rating",ajaxURL:"/enewsletters.php"},initialize:function(C,A){this.setOptions(A);this.images=$$(C);this.active=false;if(this.images==""){return }this.images.each(function(G,F){G.setStyles({"cursor":"pointer"});G.addEvent("click",function(H){H=new Event(H).stop();if(this.active){return }this.active=G;this.rate()}.bindWithEvent(this))}.bind(this));if(!this.options.baseURL){var D=document.getElementsByTagName("script");for(var B=0;B<D.length;B++){if(D[B].src&&(D[B].src.indexOf(this.options.scriptName+".js")!=-1)){var E=D[B].src;this.options.baseURL=E.substring(0,E.lastIndexOf("/"));break}}this.documentBasePath=document.location.href;if(this.documentBasePath.indexOf("?")!=-1){this.documentBasePath=this.documentBasePath.substring(0,this.documentBasePath.indexOf("?"))}this.documentBasePath=this.documentBasePath.substring(0,this.documentBasePath.lastIndexOf("/"));if(this.options.baseURL.indexOf("://")==-1&&this.options.baseURL.charAt(0)!="/"){this.options.baseURL=this.documentBasePath+"/"+this.options.baseURL}}},rate:function(){var C=this.active.id.match(/([pc])(up|down)(.+?)$/);var B=C[1];var A=C[2];var D=C[3];new Ajax(this.options.ajaxURL,{method:"post",data:"rate="+D+"&type="+B+"&chg="+A,onComplete:(function(E){this.ajaxMsg(E)}.bind(this))}).request()},ajaxMsg:function(response){this.active=this.active.getParent().getElement("em");eval(response)},logon:function(){var B=window.getSize().size;B.y=this.active.getPosition().y;this.background=new Element("div",{"styles":{"background-color":"#000000","opacity":"0.7","position":"fixed","top":"0","left":"0","width":"100%","height":"100%","z-index":"60"}}).inject(document.body);this.loginBox=new Element("div",{"styles":{"position":"absolute","top":B.y,"left":B.x/2-225,"width":"450px","z-index":"61","font":"11px Arial","background":"transparent url("+this.options.baseURL+"/box_bck.gif) repeat-x scroll center bottom","border":"1px solid #ECECEC"}}).inject(document.body);var A=new Element("div",{"styles":{"background":"#F9F9F9 none repeat scroll 0%","border":"1px solid #FFFFFF","height":"20px","padding":"5px 10px 0 10px","color":"#444444","font-weight":"bold"}}).injectInside(this.loginBox);new Element("div",{"styles":{"float":"left"}}).setHTML("LOGIN REQUIRED").injectInside(A);new Element("div",{"styles":{"color":"#f9f9f9","background-color":"#444444","padding":"0 3px","float":"right","cursor":"pointer"},"events":{"click":(function(C){C=new Event(C).stop();this.loginBox.remove();this.background.remove()}).bindWithEvent(this)}}).setHTML("X").injectInside(A);new Element("div",{"class":"box_contents","styles":{"background-color":"#ffffff","line-height":"18px","padding":"20px"}}).setHTML('<p style="padding: 0">A login is required to access this wonderful feature of the website. If you already have an account, please log in now to gain access. If you do not already have an account, you can create a free account. Creating a free account only takes a few seconds and will save you time as you take advantage of all our site features. Once you are logged into aop.com, you will no longer need to enter your demographic information each time you desire to take advantage of a particular feature on aop.com. So log in or create a free account today!</p>').injectInside(this.loginBox);this.active=false}});DataRating.implement(new Events,new Options)
