/*Example message arrays for the two demo scrollers*/

var pausecontent=new Array()
pausecontent[1]='<a href="#">New Games for July</a> July 1, 2010 - We just added a ton of new games!  Have fun :)';
pausecontent[0]='<a href="#">Updated Messaging System</a> August 10, 2010 - It\'s a whole lot better!  Sign up, login, and try it out!';

var featuredgame=new Array()
featuredgame[0]=["images/featured/acidball.png","/games/acidball/",""];
featuredgame[1]=["images/featured/jademonkey.png","/games/jade-monkey/",""];
featuredgame[2]=["images/featured/penguins.png","/games/penguin-diner-2/",""];

/*featuredgame[1]=["scripts/featured_game.php?src=../images/DEMO-featured-2.gif&p=90&imagetype=gif&backcolor=ffffff&radius=5&title=Presidential%20Paintball&desc=Hillary,%20Obama,%20Giuliani%20and%20more%20play%20paintball%20for%20the%20USA%20Presidency!","#",""];*/

function updateGameSize(id,width,height){
  temp_img=new Image();
  url="/scripts/update-gamedimentions.php?id="+id+"&height="+height+"&width="+width;
  temp_img.src=url;
}

already_rated=false;
function rateGame(gameid,rating){
  if(!already_rated){
    already_rated=true;

    rate_img=new Image();
    url="/scripts/rate-game.php?id="+gameid+"&rating="+rating;
    rate_img.src=url;

    document.getElementById("ratetext").innerHTML="Thanks for rating!";
  }else{
    alert('You have already rated this game.');
  }
}

function updateFriendOrder(f1,f2,f3,f4,f5,f6) {
       if(f1)
	f1=f1.replace("user_","");
       else
	f1="";
       if(f2)
	f2=f2.replace("user_","");
       else
	f2="";
       if(f3)
	f3=f3.replace("user_","");
       else
	f3="";
       if(f4)
	f4=f4.replace("user_","");
       else
	f4="";
       if(f5)
	f5=f5.replace("user_","");
       else
	f5="";
       if(f6)
	f6=f6.replace("user_","");
       else
	f6="";

	img=new Image();
	urltmp="/scripts/update-friendorder.php?f1="+f1+"&f2="+f2+"&f3="+f3+"&f4="+f4+"&f5="+f5+"&f6="+f6+"&nocache="+Math.floor(Math.random() * 100000);
	img.src=urltmp;

        img.onload=function(){img="";}
        img.onerror=function(){img="";}
}

function deleteFriend(recordid,friendid,friendname){
  if(confirm("Are you sure you want to delete "+friendname+" from your friends?")){
    	imgd=new Image();
	urltmp="/scripts/update-deletefriend.php?rid="+recordid+"&fid="+friendid+"&nocache="+Math.floor(Math.random() * 100000);
	imgd.src=urltmp;

        imgd.onload=function(){window.location.reload();}
        imgd.onerror=function(){window.location.reload();}
  }
}

function friendReq(rid,action_req,elemid_req){
  numoffriendrequests--;

  if(action_req=="ignore"){
    if(!confirm("Are you sure you want to ignore this friend request?"))
      return;
  }

  	img=new Image();
	urltmp="/scripts/update-acceptfriend.php?rid="+rid+"&action="+action_req+"&nocache="+Math.floor(Math.random() * 100000);
	img.src=urltmp;

        img.onload=function(){showNoticeId('action_'+action_req);Effect.Fade(elemid_req);img="";if(numoffriendrequests==0){setTimeout("Effect.Appear('nomore');",1000);}}
        img.onerror=function(){showNoticeId('action_'+action_req);Effect.Fade(elemid_req);img="";if(numoffriendrequests==0){setTimeout("Effect.Appear('nomore');",1000);}}
}


function checkElem(val,type){
  if(type=="email"){
   makeHttpRequest('/scripts/validate_field.php?t=email&v='+val, validateElemScript)
  }
  if(type=="username"){
   makeHttpRequest('/scripts/validate_field.php?t=username&v='+val, validateElemScript)
  }
  if(type=="captcha"){
   makeHttpRequest('/scripts/validate_field.php?t=captcha&v='+val, validateElemScript)
  }
}

function badElem(elem,message){
	//set a variable telling if this is invalid input
	verifiedElems[elem.id]=false
  document.getElementById(elem.id+"_notify").innerHTML="<img src=\"/images/deny.png\" /> "+message;
}
function goodElem(elem,message){
	//set a variable telling this is valid input
	verifiedElems[elem.id]=true
  document.getElementById(elem.id+"_notify").innerHTML="<img src=\"/images/accept.png\" /> "+message;
}
function blankElem(elem){
  document.getElementById(elem.id+"_notify").innerHTML="";
}
verifiedElems=[]

function clearDefaultandCSS(el) {
	if (el.defaultValue==el.value) el.value = ""
	// If Dynamic Style is supported, clear the style
	el.className="focused";
}

function changeStyle(id, classn){
  document.getElementById(id).className=classn;
}

function tl(elem){
	elem.alt=elem.href;
	elem.href="/links/out/"+elem.id+"/";
}
function ul(elem){
	if(elem.alt.length>0)
		elem.href=elem.alt;
}

function validateForm(elems){
	//validates a form checking to make sure elems
	//with ids in elems list have been verified
	
	//we want to blur all focused elements first, otherwise
	//they won't be validated first!

	var arr = new Array();
    arr = document.getElementsByTagName( "input" );
	for(var i=0; i < arr.length; i++)
            {
                arr[i].blur();
            }
	
	for(var k in elems){
		if(!verifiedElems[elems[k]]){
			alertval=document.getElementById(elems[k]).title;
			if(alertval.split("|")[0]=="(custom)"){
				alert(alertval.split("|")[1]);
			}else{
				alert("Please enter a valid "+ alertval)
			}
			document.getElementById(elems[k]).focus();
			return false;
		}
	}

	return true;
}

function newCaptcha(){
	document.getElementById('charimage').src='/scripts/captcha.php?refresh=true&rand='+Math.random()*9;setTimeout('validateElem(document.registrationForm.captcha,\'captcha\');',1000);
	}
	
function checkEmail(email) {
     AtPos = email.indexOf("@")
     StopPos = email.lastIndexOf(".")

     if (email == "") {
          return false;
     }

     if (AtPos == -1 || StopPos == -1) {
          return false;
     }

     if (StopPos < AtPos) {
          return false;
     }

     if (StopPos - AtPos == 1) {
          return false;
     }

     return true;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validateElemScript(r){
  r=trim(r);
  if(r=="<email.success>"){
     elem=document.registrationForm.email;
     goodElem(elem,"");
  }
  if(r=="<email.fail>"){
     elem=document.registrationForm.email;
     badElem(elem,"E-mail already has account");
  }
  if(r=="<username.success>"){
     elem=document.registrationForm.username;
     goodElem(elem,"");
  }
  if(r=="<username.fail>"){
     elem=document.registrationForm.username;
     badElem(elem,"Username already taken");
  }
  if(r=="<captcha.success>"){
     elem=document.registrationForm.captcha;
     goodElem(elem,"");
  }
  if(r=="<captcha.fail>"){
     elem=document.registrationForm.captcha;
     badElem(elem,"Incorrect verification code");
  }
}

passvalid=false;
function validateElem(elem,type){
  if(type=="email"){
    if(checkEmail(elem.value)){
     //send it to the server to see if an account exists, otherwise
     checkElem(elem.value,'email');
    }else{
     //bad address
     badElem(elem,"Not a valid e-mail address");
    }
  }
  
  if(type=="check"){
    if(elem.checked){
     //its checked, good!
     goodElem(elem,'');
    }else{
     //bad address
     badElem(elem,"");
    }
  }
  
  if(type=="email-contact"){
    if(checkEmail(elem.value)){
     //send it to the server to see if an account exists, otherwise
     goodElem(elem,'');
    }else{
     //bad address
     badElem(elem,"Not a valid e-mail address");
    }
  }
  
  if(type=="text"){
    if(elem.value.length>=1 && elem.value.length<=1000){
     goodElem(elem,'');
    }else if(elem.value.length<1){
     badElem(elem,'');
    }else{
     //bad text
     badElem(elem,'No more than 1000 characters');
    }
  }

  if(type=="username"){
    if(isAlphanumeric(elem.value) && elem.value.length>=3 && elem.value.length<=12){
     //send it to the server to see if an account exists, otherwise
     checkElem(elem.value,'username');
    }else if(elem.value.length<3){
     badElem(elem,"Must be at least 3 characters");
    }else if(elem.value.length>12){
     badElem(elem,"Must be no more than 12 characters");
    }else{
     //bad username
     badElem(elem,"Must be only numbers and letters");
    }
  }

  if(type=="captcha"){
    if(isAlphanumeric(elem.value) && elem.value.length==4){
     //send it to the server to see if its correct, otherwise
     checkElem(elem.value,'captcha');
    }else if(elem.value.length!=4){
     badElem(elem,"Must be 4 characters");
    }else{
     //bad captcha
     badElem(elem,"Invalid characters entered");
    }
  }

  if(type=="password"){
    if(elem.value.length>=5 && elem.value.length<=18){
     //send it to the server to see if an account exists, otherwise
     goodElem(elem,"");
     passvalid=true;
    }else if(elem.value.length<5){
     badElem(elem,"Must be at least 5 characters");
     passvalid=false;
    }else{
     badElem(elem,"Must be no more than 18 characters");
     passvalid=false;
    }
    validateElem(document.registrationForm.password_confirm,"password_confirm");
  }

  if(type=="password_confirm"){
    if(elem.value==document.registrationForm.password.value && passvalid){
     //send it to the server to see if an account exists, otherwise
     goodElem(elem,"");
    }else if(passvalid){
     badElem(elem,"Passwords do not match");
    }else{
     blankElem(elem);
    }
  }
}

function isAlphanumeric(str){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(str.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function highlightSubscribe(action){
   if(action){
      document.getElementById("subscribe").className="subscribe-box-over";
   }else{
      document.getElementById("subscribe").className="subscribe-box";
   }
}
function highlightSearch(action){
   if(action){
      document.getElementById("search").className="search-box-over";
   }else{
      document.getElementById("search").className="search-box";
   }
}
function highlightLogin(action){
   if(action){
      document.getElementById("login-button").className="loginButton-down";
   }else{
      document.getElementById("login-button").className="loginButton";
   }
}


function showNotice(){
     if(document.getElementById("datasaved").style.display=="none"){
       fadeIn('datasaved',10,200);
       setTimeout("fadeOut('datasaved',20,1500);",2000);
     }
}

function showNoticeId(id){
     if(document.getElementById(id).style.display=="none"){
       fadeIn(id,10,200);
       setTimeout("fadeOut('"+id+"',20,1500);",2000);
     }
}


/***********************************************
* BEGIN CLASS FOR AJAX
***********************************************/

function makeHttpRequest(url, callback_function, return_xml)
{
 var http_request, response, i;

 var activex_ids = [
   'MSXML2.XMLHTTP.3.0',
   'MSXML2.XMLHTTP',
   'Microsoft.XMLHTTP'
 ];

 if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+...
   http_request = new XMLHttpRequest();
   if (http_request.overrideMimeType) {
     http_request.overrideMimeType('text/xml');
   }
 } else if (window.ActiveXObject) { // IE6 and older
   for (i = 0; i < activex_ids.length; i++) {
     try {
       http_request = new ActiveXObject(activex_ids[i]);
     } catch (e) {}
   }
 }

 if (!http_request) {
   
   return false;
 }

 http_request.onreadystatechange = function() {
   if (http_request.readyState !== 4) {
       // not ready yet
       return;
   }
   if (http_request.status !== 200) {
     // ready, but not OK
     if(http_request.status!=0)
     	alert('There was a problem with the request.(Code: ' + http_request.status + ')');
     return;
   }
   if (return_xml) {
     response = http_request.responseXML;
   } else {
     response = http_request.responseText;
   }
   // invoke the callback
   callback_function(response);
 };

 http_request.open('GET', url, true);
 http_request.send(null);
}

/***********************************************
* BEGIN CLASS FOR FADES
***********************************************/
        function setOpacity(id, level) {            
            level=level*.80;
            var element = document.getElementById(id); 
            element.style.display = 'inline';           
            element.style.zoom = 1;
            element.style.opacity = level;
            element.style.MozOpacity = level;
            element.style.KhtmlOpacity = level;
            element.style.filter = "alpha(opacity=" + (level * 100) + ");";
        }

        function fadeIn(id, steps, duration){  
            var fadeInComplete;      
            for (i = 0; i <= 1; i += (1 / steps)) {
              setTimeout("setOpacity('" + id + "', " + i + ")", i * duration); 
              fadeInComplete = i * duration;             
            }      
        }

        function fadeOut(id, steps, duration) {         
            var fadeOutComplete;       
            for (i = 0; i <= 1; i += (1 / steps)) {
              setTimeout("setOpacity('" + id + "', "  + (1 - i) + ")", i * duration);
              fadeOutComplete = i * duration;
            }      
            //completely hide the displayed message after the fade effect is complete              

            setTimeout("hide('" + id + "')", fadeOutComplete);     
        }   

        function hide(id){
            document.getElementById(id).style.display = 'none';     
        }



/***********************************************
* BEGIN CLASS FOR FRIEND ORDERING
***********************************************/
	function saveOrder(item) {
		var group = item.toolManDragGroup
		var list = group.element.parentNode
		var id = list.getAttribute("id")
		if (id == null) return
		group.register('dragend', function() {
			savestr=junkdrawer.serializeList(list);
			savestr=savestr.split("|");

			if(newOrder(savestr)){
				updateFriendOrder(savestr[0],savestr[1],savestr[2],savestr[3],savestr[4],savestr[5]);
				clearFriendStyling();
				setFriendStyling(savestr[0],savestr[1],savestr[2],savestr[3],savestr[4],savestr[5]);
				setCurrentOrder();
				showNotice();
			}
		})
	}

	function setCurrentOrder(){
		var list = document.getElementById("boxes-edit");

		curr=junkdrawer.serializeList(list);
		curr=curr.split("|");
		
                currorder=new Array();

		currorder[0]=curr[0];
		currorder[1]=curr[1];
		currorder[2]=curr[2];
		currorder[3]=curr[3];
		currorder[4]=curr[4];
		currorder[5]=curr[5];
	}

	function newOrder(str){
		if(currorder[0]==str[0] &&
			currorder[1]==str[1] &&
			currorder[2]==str[2] &&
			currorder[3]==str[3] &&
			currorder[4]==str[4] &&
			currorder[5]==str[5])

			return false;
		else
			return true;
	}

	function clearFriendStyling(){
		arr=document.getElementsByTagName("li");
		for(i=0;i<arr.length;i++){
			if(arr[i].id.indexOf("user_")>-1){
				arr[i].className="";
			}
		}
	}

	function setFriendStyling(f1,f2,f3,f4,f5,f6){
               if(f1)
		document.getElementById(f1).className="topfriendedit";
               if(f2)
		document.getElementById(f2).className="topfriendedit";
               if(f3)
		document.getElementById(f3).className="topfriendedit";
               if(f4)
		document.getElementById(f4).className="topfriendedit";
               if(f5)
		document.getElementById(f5).className="topfriendedit";
               if(f6)
		document.getElementById(f6).className="topfriendedit";
	}


/***********************************************
* Ultimate Fade-In Slideshow (v1.51): &#169; Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=featuredgame;
var fadebgcolor="white"

////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}


/***********************************************
* Pausing up-down scroller- &#169; Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}



//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
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 = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  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":
        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 "id":
      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;
}

//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AX_RunContent(){
  var ret = AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  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 "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      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":
        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];
    }
  }
  return ret;
}

