var avatar = ["http://i.livescience.com/common/community/template_images/Avatar_imaginova_gray.jpg", "http://i.livescience.com/common/community/template_images/Avatar_imaginova.jpg"];
var SOloc = "http://dev.spaceholdings.com/imaginova/communities/";
var captchaKey = "6LcVvwAAAAAAAMRouTmot0uuPtO3DE2a33dTegK1";
function chk_form(obj){
var err = false;
var e = Form.getInputs($(obj));
for( var i = 0; i < e.length; i++){
if(e[i].alt == 'req' && e[i].present() != true ){
e[i].addClassName('error');
if(e[i].title != '' && $('err_'+e[i].id) == null){
var em = new Element('span',{'id':'err_'+e[i].id, 'class':'error_msg' }).update(e[i].title);
e[i].parentNode.appendChild(em);
}
err = true;
}
}
if(err === true){
return false;
}else{ return true; }
}
var FlashTag = Class.create({
initialize: function(src, width, height) {
this.src = src;
this.width = width;
this.height = height;
this.version = '7,0,14,0';
this.id = null;
this.bgcolor = 'ffffff';
this.flashVars = null;
this.chkflash();
},
setVersion: function(v){ this.version = v },
setId: function(id){ this.id = id; },
setBgcolor: function(bgc){ this.bgcolor = bgc; },
setFlashvars: function(fv){ this.flashVars = fv; },
toString: function(){
var flashTag = new String();
if(ie){
flashTag += '';
}else{
flashTag += '';
}
return flashTag;
},
write: function(doc){ doc.write(this.toString()); },
chkflash: function(){ //// Need to add in plugin check //////
this.plugin = true;
}
});
function Clean(cmt) {
var clean="";
if(cmt.length>0){
var clean=cmt.replace(//g,">");
clean=clean.replace(/\u2019/g,"’");
clean=clean.replace(/\u201C/g,"“");
clean=clean.replace(/\u201D/g,"”");
clean=clean.replace(/\r\n/g,"\n");
clean=clean.replace(/\n/g,"
\n");
}
return (clean);
}
var tab_group = Class.create({
initialize: function(nav, win, pos) {
this.cur_tab = pos;
this.tabs = new Array($(nav).childElements(), $(win).childElements());
this.tabs[0][pos].addClassName('active');
this.tabs[1][pos].addClassName('active');
for(var i=0; i 0)? this.group[0] : this.id;
if(!this.tabs[0]) return;
if(!this.views[0]) return;
try{
var m = (id == 'dw_pop')? 0 : (this.tabs.length-1)*5;
var w = ($(id).hasClassName('disc_mod'))? (($(id).offsetWidth - m) / this.tabs.length)-2 : Math.floor((this.group.offsetWidth - 2) / this.tabs.length);
for(var i=0; i < this.tabs.length; i++){
if(id != 'top-list') this.tabs[i].style.width = Math.ceil(w)+"px";
if( this.tabs.length == 1)this.tabs[i].style.margin = 0;
Event.observe(this.tabs[i], 'click', this.action.bindAsEventListener(this,i));
}
try{
if($(this.id.parentNode).hasClassName('col4')){
var list = this.id.getElementsByTagName('dl').item(0);
for(var i=0; i < this.tabs.length; i++){
list.appendChild(this.tabs[0]);
list.appendChild(this.views[0]);
}
}
}catch(e){ }
this.tabs[0].addClassName('active');
this.views[0].style.display = "block";
}catch(e){ alert(e); }
},
action: function(event, n){
this.tabs[this.cur_tab].removeClassName('active');
this.views[this.cur_tab].style.display = 'none';
this.tabs[n].addClassName('active');
this.views[n].style.display = 'block';
this.cur_tab = n;
}
});
var carousel = Class.create({
initialize: function(items) {
this.main_obj = $('carousel');
this.objwrapper = $('carouselwrapper');
if(!this.main_obj) return;
this.pos = 0;
this.moduleLimit = items;
this.moveby = items-1;
this.duration = 1; // seconds
this.disabled = false;
this.elements = this.main_obj.getElementsByTagName("li").length;
this.objwidth = this.main_obj.getElementsByTagName("li").item(0).offsetWidth;
if(this.elements <= this.moduleLimit){
$('carousel_next').style.display = "none";
$('carousel_prev').style.display = "none";
return;
}
if(this.elements <= this.moduleLimit + this.moveby ){
this.moveby = this.elements - this.moduleLimit;
this.duration = (this.elements - 3)*.1;
}
this.shiftBy = this.moveby * this.objwidth;
this.content_obj = this.main_obj.getElementsByTagName("ul").item(0);
this.content_obj.style.width = this.elements * this.objwidth+"px";
/* PRIME EFFECTS */
new Effect.MoveBy(this.objwrapper, 0, 0, {duration: 0.0, transition: Effect.Transitions.sinoidal});
this.setControls($('carousel_next'), "-16px", this.next_item.bindAsEventListener(this));
this.setControls($('carousel_prev'), "0px", this.prev_item.bindAsEventListener(this));
},
next_item: function(event){
if(this.disabled) return;
this.disabled = true;
this.shift = this.shiftBy*-1;
if(this.pos < 0 ){
for(var i= 0; i < this.moveby; i++){
this.content_obj.appendChild(this.content_obj.firstDescendant());
}
this.pos = 0;
this.objwrapper.style.left = "0px";
}
this.action();
},
prev_item: function(event){
if(this.disabled) return;
this.disabled = true;
this.shift = this.shiftBy;
if(this.pos >= 0 ){
for(var i= 1; i <= this.moveby; i++){
Element.insert(this.content_obj, {top: this.content_obj.getElementsByTagName("li").item(this.elements-1)} )
}
this.pos = this.shiftBy * -1;
this.objwrapper.style.left = this.pos+"px";
}
this.action();
},
action: function() {
this.pos += this.shift;
new Effect.MoveBy(this.objwrapper, 0, this.shift, {duration: this.duration, transition: Effect.Transitions.sinoidal, afterFinish: this.disabled = false })
},
end: function(event) {
//updateItems(mycarousel);
this.disabled = false;
},
setControls: function(obj, left, f) {
Event.observe(obj, 'mouseover', function(e){ obj.style.backgroundPosition = left +" top"; });
Event.observe(obj, 'mouseout', function(e){ obj.style.backgroundPosition = left +" bottom"; });
Event.observe(obj, 'click', f);
}
})
var related_module = Class.create({
initialize: function() {
this.cur_img = 0;
this.images = $('related_images_module').getElementsByTagName("dt");
this.caption = $('related_images_module').getElementsByTagName("dd");
this.cnt = this.images.length
if(this.cnt > 1){
var next = new set_control($('ri_next'), 'http://i.livescience.com/template_images/buttons/btn_nextsm.gif', 'http://i.livescience.com/template_images/buttons/btn_nextsm_inactive.gif', function(e){ related_images.next_img(this) });
var prev = new set_control($('ri_prev'), 'http://i.livescience.com/template_images/buttons/btn_prevsm.gif', 'http://i.livescience.com/template_images/buttons/btn_prevsm_inactive.gif', function(e){ related_images.prev_img(this) });
}else{
$('ri_next').style.display = "none";
$('ri_prev').style.display = "none";
}
Event.observe('ri_enlarge', 'click', this.navigate);
this.populate(this.cur_img);
},
populate: function(n){
var lnk = this.images[n].getElementsByTagName("a")[0].href;
$('ri_imgHolder').innerHTML = this.images[n].innerHTML;
$('ri_caption').innerHTML = this.caption[n].innerHTML;
$('ri_count').innerHTML = (this.cur_img+1) + " of " + this.cnt;
$('ri_enlarge').innerHTML = 'Full Size';
},
next_img:function(event){
this.cur_img = (this.cur_img >= this.cnt)? 0 : this.cur_img+1;
this.populate(this.cur_img);
},
prev_img:function(event ){
this.cur_img = (this.cur_img <= 0)? this.cnt : this.cur_img-1;
this.populate(this.cur_img);
},
navigate:function(){
//window.location = myrelated.obj_dat[myrelated.cid].href;
}
});
var related_resource_module = Class.create({
initialize: function() {
this.cur_img = 0;
this.images = $('related_resources_module').getElementsByTagName("dt");
this.caption = $('related_resources_module').getElementsByTagName("dd");
this.cnt = this.images.length;
if(this.cnt > 1){
var next = new set_control($('rr_next'), 'http://i.livescience.com/template_images/buttons/btn_nextsm.gif', 'http://i.livescience.com/template_images/buttons/btn_nextsm_inactive.gif', function(e){ related_resources.next_img(this) });
var prev = new set_control($('rr_prev'), 'http://i.livescience.com/template_images/buttons/btn_prevsm.gif', 'http://i.livescience.com/template_images/buttons/btn_prevsm_inactive.gif', function(e){ related_resources.prev_img(this) });
}else{
$('rr_next').style.display = "none";
$('rr_prev').style.display = "none";
}
Event.observe('rr_enlarge', 'click', this.navigate);
this.populate(this.cur_img);
},
populate: function(n){
var lnk = this.images[n].getElementsByTagName("a")[0].href;
$('rr_imgHolder').innerHTML = this.images[n].innerHTML;
$('rr_caption').innerHTML = this.caption[n].innerHTML;
$('rr_count').innerHTML = (this.cur_img+1) + " of " + this.cnt;
$('rr_enlarge').innerHTML = 'Play Video';
},
next_img:function(event){
this.cur_img = (this.cur_img >= this.cnt)? 0 : this.cur_img+1;
this.populate(this.cur_img);
},
prev_img:function(event ){
this.cur_img = (this.cur_img <= 0)? this.cnt : this.cur_img-1;
this.populate(this.cur_img);
},
navigate:function(){
//window.location = myrelated.obj_dat[myrelated.cid].href;
}
});
var init_Galleries = Class.create({
initialize: function(id) {
this.current = 0;
this.id = $(id);
this.img = $(id).getElementsByTagName('dt');
this.desc = $(id).getElementsByTagName('dd');
this.type = ($('topten'))? 'topten' : 'gallery';
if($('img_progress')){
this.bar = $('img_progress').getElementsByTagName('input').item(0);
this.bar_txt = $('img_progress').getElementsByTagName('h5').item(0);
}else if($('ri_count')){
this.bar = false;
this.bar_txt = $('ri_count');
}else if($('topten')){
var count = $('countdown').getElementsByTagName("li");
for(var i=0; i < count.length; i++){
count[i].setAttribute('value', i);
count[i].setAttribute('id', 'num_'+i);
Event.observe(count[i], 'click', this.update.bindAsEventListener(count[i],this));
}
}
this.set_progress();
},
next: function(){
if(this.current < this.img.length){
this.desc[this.current].style.display = "none";
this.img[this.current].style.display = "none";
if(this.type == 'topten') $('num_'+this.current).removeClassName('selected');
this.current++;
this.set_progress();
if (this.current == this.img.length-1)
{
buttonurl = document.getElementById('nextimg').src.split('buttons');
document.getElementById('nextimg').src = buttonurl[0] + 'buttons/btn_backintro.gif';
document.getElementById('nextimg').width = 128;
introurl = document.location.href.split('-1.');
document.getElementById('next').href = introurl[0]+'.html';
}
if(typeof(_hbPageView) == 'function')_hbPageView(page,section);
refreshAds();
}
},
prev: function(){
if(this.current-1 >= 0){
this.desc[this.current].style.display = "none";
this.img[this.current].style.display = "none";
if(this.type == 'topten') $('num_'+this.current).removeClassName('selected');
var previous = this.current;
this.current--;
this.set_progress();
if (previous == this.img.length-1 && this.current == this.img.length-2)
{
buttonurl = document.getElementById('nextimg').src.split('buttons');
document.getElementById('nextimg').src = buttonurl[0] + 'buttons/btn_next_active.gif';
document.getElementById('nextimg').width = 50;
document.getElementById('next').href = "javascript:topten.next();";
}
if(typeof(_hbPageView) == 'function')_hbPageView(page,section);
refreshAds();
}
},
update: function(obj,f){
var previous = f.current;
f.desc[f.current].style.display = "none";
f.img[f.current].style.display = "none";
$('num_'+f.current).removeClassName('selected');
f.current = this.getAttribute('value');
f.set_progress();
if (f.current == f.img.length-1)
{
buttonurl = document.getElementById('nextimg').src.split('buttons');
document.getElementById('nextimg').src = buttonurl[0] + 'buttons/btn_backintro.gif';
document.getElementById('nextimg').width = 128;
introurl = document.location.href.split('-1.');
document.getElementById('next').href = introurl[0]+'.html';
}
if (f.current < f.img.length-1)
{
buttonurl = document.getElementById('nextimg').src.split('buttons');
document.getElementById('nextimg').src = buttonurl[0] + 'buttons/btn_next_active.gif';
document.getElementById('nextimg').width = 50;
document.getElementById('next').href = "javascript:topten.next();";
}
if(typeof(_hbPageView) == 'function')_hbPageView(page,section);
refreshAds();
},
link: function(){
var goto = this.img[this.current].getElementsByTagName('a').item(0);
window.location = goto.href;
},
set_progress: function(){
if(this.type == 'gallery'){
if(this.bar){
var output = "IMAGE "+(this.current+1)+" of "+this.img.length;
this.bar.style.backgroundPosition = (((this.current+1)/this.img.length)*150)-150+"px 0px";
}else{
var output = (this.current+1)+" of "+this.img.length;
}
this.bar_txt.innerHTML = output;
$('next').style.backgroundPosition = (this.current+1 < this.img.length)?'bottom':'top';
$('prev').style.backgroundPosition = (this.current > 0)?'bottom':'top';
}
if(this.type == 'topten'){
$('num_'+this.current).addClassName('selected');
}
this.desc[this.current].style.display = "block";
this.img[this.current].style.display = "block";
}
});
function ts_size(s, id){
if(!$(id).style.fontSize){ var size=1.3; }
else{
var size = $(id).style.fontSize.split("em");
size = size.shift();
}
if(s == 'min'){
$(id).style.fontSize = size-0.2+"em";
}else{
$(id).style.fontSize = Math.abs(size)+0.2+"em";
}
}
var set_control = Class.create({
initialize: function(obj, active, inactive, f) {
Event.observe(obj, 'mouseover', function(e){ obj.src = active; });
Event.observe(obj, 'mouseout', function(e){ obj.src = inactive; });
Event.observe(obj, 'click', f);
}
});
var sect = document.URL.split("/");
function setNav(){
try{
nav_obj = $('navigation').getElementsByTagName('a');
if(nav_obj.length > 1){
for(n=1; n < nav_obj.length; n++){
var h = document.URL.split(nav_obj[n].getAttribute('href'));
if(h.length >= 2) nav_obj[n].className = "selected";
}
}
}catch(e){}
}
Event.observe(window, 'load', setNav, false);
var showPrint = Class.create({
initialize: function() {
var obj = document.body;
this.copy = Object.clone(obj);
this.text = ($('article_text'))? $('article_text').innerHTML : $('article-copy').innerHTML;
this.image = $('related_images_module');
$('main').style.display = 'none';
$('ibar').style.display = 'none';
obj.addClassName('print_art');
if($('article_text')){
var hd = $('headline').innerHTML;
}else{
var hd = ""+ document.getElementsByTagName('h1')[0].innerHTML + "
" + document.getElementsByClassName('article-head')[0].getElementsByTagName('h4')[0].innerHTML + "
";
}
var str = '';
str += '
';
str += '';
str += '' + hd + '
'+this.text;
str += '';
obj.innerHTML = str;
if(this.image){ $('related_images_module').style.display = 'none'; }
}
});
function show_share(pos){
$('share_items').style.display = ($('share_items').style.display == "none")?"block":"none";
if(pos == 'left'){
var w = ($('tb_share').offsetLeft + $('tb_share').offsetWidth) - $('share_items').offsetWidth;
$('share_items').style.left = w+"px";
}else{
$('share_items').style.right = "0px";
}
}
function searchType(n,t){
$('searchType').value = t;
var tabs = $('searchTypeTab').getElementsByTagName('li');
for(var i=0; i < tabs.length; i++){
if(i == n){ tabs[i].addClassName('active'); }
else{ tabs[i].removeClassName('active'); }
}
}
function pagination(p,f){
if (p < 0) pagenb = 0;
$(f).page.value = p;
$(f).submit();
return;
}
function hbxMedia(vFileName,vCurrentPos,vEndPos,vAction){
_hbSet('m.s',vAction);
_hbSet('m.f',vFileName);
_hbSet('m.cp',vCurrentPos);
_hbSet('m.ep',vEndPos);
_hbSet('m.cl','Flash Player');
_hbSet('m.cv','9.0');
_hbSet('m.tt','e');
_hbSend();
}