// check if google can index pages with javascripts - or just replace "#" with some path

function inject() {
//document.attachEvent('scroll', xmove);
section=document.getElementById('cool-flyer');
intop = section.offsetTop; inheight = section.offsetHeight;
overflow = intop +inheight -window.innerHeight +160;
section.style.width=section.offsetWidth+'px';
document.addEventListener('scroll', xmove, false);
// some of these need to be reloaded during window rezise
};

function xmove() {
if (window.pageYOffset > overflow)
{pos='fixed';bot=160;} else {pos='relative';bot=0;}
section.style.position=pos;section.style.bottom=bot+'px';
};

function showframe(thetitle){
showOdiogoReadNowFrame('48055', thetitle, '10', 200, 100);
//if (1==1){pxs='50px';space=true}else{pxs='0px';space=false};
if (space==false){pxs='50px';space=true}else{pxs='0px';space=false};
document.getElementById('iframe_odiogo_10').style.height=pxs;
document.getElementById('odiogo-space').style.height=pxs;
};

function submit(url){
query='http://'+url+'='+post_url+'&title='+escape(post_title);
title=escape(post_title);

// query+='&bodytext='+title; // digg
query+='&h='+title; // newsvine
query+='&T='+title; // propeller
query+='&bm_description='+title; // mr. wong
window.open(query);
};

function switch_css(dark_hue,light_hue,hue,fullsat){
accent_colors=dark_hue+light_hue+hue+fullsat;
document.getElementById('recentposts').style.backgroundColor='#'+dark_hue; 
document.getElementById('top-accent-rule').style.backgroundColor='#'+hue; 
// document.getElementById('rightbav-bkg').style.backgroundColor='#'+dark_hue;
document.getElementById('buttons').style.backgroundColor='#'+fullsat;
// document.getElementById('is_on').style.backgroundColor='#'+light_hue;

leftedge_on=document.getElementById('leftedge-on');
// hasrule=document.getElementById('color-rule');
// if (hasrule!=null){hasrule.style.backgroundColor='#'+light_hue;};
if (leftedge_on!=null){leftedge_on.style.backgroundColor='#'+light_hue;};

for(i=0;i<classes.length;i++){classes[i].style.backgroundColor='#'+light_hue;}
};

function getElementsByClass(searchClass,node,tag) {
classElements = new Array();
if (node==null){node=document};if (tag==null){tag='*'};
els=node.getElementsByTagName(tag);elsLen=els.length;
pattern=new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
for (i=0,j=0;i<elsLen;i++){
if (pattern.test(els[i].className)){classElements[j]=els[i];j++;}
}return classElements;
};

function write_hue(){
somedate='; expires=Wed, 1 Jan 2020 12:00:00 UTC;path=/';
document.cookie='accentcolors=' +accent_colors +somedate;
};

function get_cookie() {
cookiebag=document.cookie.split(';');
for(i=0;i<cookiebag.length;i++) {
cook=cookiebag[i].replace(' ','');
if (cook.substr(0,12)=='accentcolors'){return cook}}
return 'accentcolors=2385b3def4ff00aeff0040ff';}

function get_colors(){
cookie_contents = get_cookie() ;
accent_dark = cookie_contents.substr(13,6);
accent_light = cookie_contents.substr(19,6);
accent = cookie_contents.substr(25,6);
accent_fullsat = cookie_contents.substr(31,6);

var bodycontent=document.getElementById('bodycontent');
classes=getElementsByClass('color-rule',bodycontent,'div');
switch_css(accent_dark,accent_light,accent,accent_fullsat);
};

function set_rightnav_height(rightnav_element){
leftnav_h=document.getElementById('leftnav').offsetHeight +50;
body_h=document.getElementById('bodycontent').offsetHeight +50;
rightnav_element.style.height = Math.max(leftnav_h,body_h)+'px';
};
