var _Common_ = {
	initRollovers:function(){
		if (!document.getElementById) return
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
		var img_Len = aImages.length;
		for (var i = 0; i < img_Len; i++) {		
			if (aImages[i].className == 'over') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_over'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_x'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		} 
		
		var aInputs = document.getElementsByTagName('input');
		var img_Len = aInputs.length;
		for (var i = 0; i < img_Len; i++) {		
			if (aInputs[i].className == 'over') {
				var src = aInputs[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_over'+ftype);
	
				aInputs[i].setAttribute('hsrc', hsrc);
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				aInputs[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				aInputs[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_x'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}   
		return;
	},
	rand:function(x){
		number = Math.floor(Math.random() * x);
		return number;
	},
	url_Parse:function(url){
		var _ = false;
		if(url.indexOf("?") > 0 && url.indexOf("=") > 0){
			_ = new Array();
			var array = url.split("#");
			array = array[0].split("?");
			array = array[1].split("&");
			for(var i=0;i<array.length;i++){
				array[i] = array[i].split("=");
				var hash = array[i][0];
				var value = array[i][1];
				
				_[hash] = value;
			}
			delete array;
		}
		return _;
	},
	scrollInit:function(){
		$('a[href^=#]').click(function(){
			var href= this.hash;
			var $target = $(href == '#TOP' ? 'body' : href);
			if($target.size()){ 
				var top = $target.offset().top; 
				$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop:top}, 1000, 'easeOutCubic',function(){
				
					location.href = href;
//					location.replace(href);				
				}); 
				return false;
			}
		})
		$('area[href^=#]').click(function(){
			var href= this.hash;
			var $target = $(href == '#TOP' ? 'body' : href);
			if($target.size()){ 
				var top = $target.offset().top; 
				$($.browser.safari ? 'body' : 'html')
				.animate({scrollTop:top}, 1000, 'easeOutCubic',function(){
				
					location.href = href;
//					location.replace(href);				
				}); 
				return false;
			}
		})
	
	},
	popupWindow:function(url, width, height, option, windowName){
		if (!width) width = window.innerWidth || document.documentElement.clientWidth;
		if (!height) height = window.innerHeight || document.documentElement.clientHeight;
		if (!option) option = 'menubar=yes, toolbar=yes, location=yes, status=yes, scrollbars=yes, resizable=yes';
		if (!windowName) windowName = "popup";
		var x = (screen.availWidth - width)/2;
		var y = (screen.availHeight - height)/3;
		var o = option+', width='+width+', height='+height+', left='+x+', top='+y;
		var win = window.open(url, windowName, o);
		
		if (win){
			win.focus();
			return false;
		} else {
			return true;
		}
	}
};
var Cookie = { //cookie
	read:function(CookieName){
		if(document.cookie){
			var cookie_Data = document.cookie;
			var Name =cookie_Data.indexOf(CookieName + "=",0);
			if(Name >= 0){
				var Data = cookie_Data.indexOf(";",Name + CookieName.length + 1);
				Data >= 0? Data = cookie_Data.substring(Name + CookieName.length + 1,Data): Data = cookie_Data.substring(Name + CookieName.length + 1,cookie_Data.length);
				return(Data);
			}
		}
		return(false);
	},
	set:function(CookieName,Value){
		var time =new Date();
		time.setTime(time.getTime() + (1000*365*60*60*24));
		var exptime =";expires=" + time.toGMTString();
		document.cookie = CookieName + "=" + Value + exptime + "; path=/";
	},
	Delete:function(CookieName){
		var time =new Date();
		time.setTime(time.getTime() - (1000*365*60*60*24));
		var exptime =";expires=" + time.toGMTString();
		document.cookie = CookieName + "=" + exptime + "; path=/";
	}
}

$(function($) {
	_Common_.initRollovers();
	_Common_.scrollInit();
	
	if(document.URL.indexOf("#comments") > 0){
		$("#respond").show();
		
	}
	$(".subPhoto a").colorbox();
	
});


function get_flash_version() {
 var version='0.0.0';
 if(navigator.plugins && navigator.mimeTypes['application/x-shockwave-flash']){
  var plugin=navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin;
  // the code below is used in SWFObject
  //var plugin=navigator.plugins['Shockwave Flash'];
  if (plugin && plugin.description) {
   // convert the description like 'Shockwave Flash 9.0 r28' into version string like '9.0.8';
   // regex is provided by SWFObject
   version=plugin.description.replace(/^[A-Za-z\s]+/, '').replace(/(\s+r|\s+b[0-9]+)/, ".");
  }
  
 } else { // in the case of Win IE
  var x='';
  try {
   // for ver.7 and later
   var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
   x=axo.GetVariable("$version");
  } catch(e) {
   try {
    // for ver.6
    axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
    x="WIN 6,0,21,0";
    /*
     * GetVariable() crashes player version 6.0.22-29, and
     * players which have those versions throws when access 
     * to AllowScriptAccess
     */
    axo.AllowScriptAccess="always";
    x=axo.GetVariable("$version");
   } catch(e) {
    if (!x.match(/^WIN/)) {
     try {
      // for 4.x,5.x
      axo=null;
      axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      // version 3 player throws when you call GetVariale().
      x=axo.GetVariable("$version");
     } catch(e) {
      if (axo) {
       // for 3.x
       x="WIN 3,0,18,0";
      } else {
       try {
        // for 2.x
        axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
        x="WIN 2,0,0,11";
       } catch(e) {
        x="WIN 0,0,0,0";
       }
      }
     }
    }
   }
  }
  // convert ActiveX version string to our version string like '9.0.28'
  version=x.replace(/^WIN /,'').replace(/,[0-9]+$/,'').replace(/,/g,'.');
 }
 // check version string format
 // Quicktime enabled Safari returns a description in natural language
 if (version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
  return version;
 } else {
  return '0.0.0';
 }
}



