/*______________________________________

  commons&sense entrance #090408
  
  Copyright (c) 2007 commons&sense. All rights reserved.
  http://www.commons-sense.net/
______________________________________*/


 var issue_cs     = '38'; // commons&sense
 var issue_cs_man = '08'; // commons&sense man 


 var photos_path = '/images/';
 var cs_w, cs_m;

 function displayRandomImage(type, url) {
  var prefix = "front_" + type;
  var imgId = '0' + Math.floor(Math.random() * 3 + 1);
  var issue = (type == "cs_man") ? issue_cs_man : issue_cs;
  var img_src = prefix + issue + '_' + imgId + '.jpg';
  var altText = (type == "cs_man") ? "commons&sense man" : "commons&sense";
  
  document.open();
  document.write('<div class="photo"><a href="'+url+'"><img src="' + photos_path + img_src + '" alt="' + altText + '" \/><\/a><\/div>');
  document.close();
 }

 function coverItemApp(self,containerId) {
  this.self = self;
  this.containerId = containerId;
  this.imagesPath = '/images/';
  this.logoImgElmt = miz$(this.containerId).getElementsByTagName('h1')[0].getElementsByTagName('img')[0];
  this.enterText = miz$(this.containerId).getElementsByTagName('p')[1];
  this.photoElmt = miz$(this.containerId).getElementsByTagName('div')[0];
  this.init();
 }

 coverItemApp.prototype = {
 
  init : function() {
   this.photoElmt.js = this.enterText.js = this.logoImgElmt.js = this;
   this.photoElmt.onmouseover = this.enterText.onmouseover = this.logoImgElmt.onmouseover = function() {
    this.js.focus();
   };
   this.photoElmt.onmouseout  = this.enterText.onmouseout  = this.logoImgElmt.onmouseout  = function() {
    this.js.blur();
   };
  },
 
  focus : function() {
   mizuyari.addClass(miz$(this.containerId), 'focus');
   this.logoImgElmt.src = this.imagesPath + this.containerId + '_o.gif';
  },

  blur : function() {
   mizuyari.removeClass(miz$(this.containerId), 'focus');
   this.logoImgElmt.src = this.imagesPath + this.containerId + '.gif';
  }
  
 }

 function entrance_Init() {
  cs_w = new coverItemApp('cs_w','enter-commons-sense');
  cs_m = new coverItemApp('cs_m','enter-commons-sense-man');
 }
 
 mizuyari.addOnLoadEvent(entrance_Init);
