/*

Image Caption v1.3
(c) Arc90, Inc.

http://www.arc90.com
http://lab.arc90.com

Licensed under : Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/

*/

/* Globals */
var arc90_navigator = navigator.userAgent.toLowerCase();
var arc90_isOpera = arc90_navigator.indexOf('opera') >= 0? true: false;
var arc90_isIE = arc90_navigator.indexOf('msie') >= 0 && !arc90_isOpera? true: false;
var arc90_isSafari = arc90_navigator.indexOf('safari') >= 0 || arc90_navigator.indexOf('khtml') >= 0? true: false;

function arc90_imgcaption() {
	var O = document.getElementsByTagName('P'); // For safari???
	for (var i = 0, l = O.length; i < l; i++)
		O[i].appendChild(arc90_newNode('span'));

	O = $$('.article_contents img');
	for (i = 0, l = O.length; i < l; i++) {
		var o = O[i];
		if (o != null && o.id!='signoff' && !o.hasClassName('nocap')) {
			try {
				var s = arc90_newNode('div', 'arc90_imgcaption'+ i, 'arc90_imgcaption'+ (o.align == 'right'? ' floatr': ' floatl'));
        var clearer = arc90_newNode('div', '', 'clearer');

				var I = o.cloneNode(true);
				I.className = 'arc90_imgcaptionIMG';

				s.appendChild(I);
				
				var x = arc90_newNode('p', '', 'arc90_imgcaptionTXT');
				var y = arc90_newNode('p', '', 'arc90_imgcaptionALT');
				var z = arc90_newNode('span', '', 'arc90_imgcaptionALT');

				if (o.alt != '') {
					z.innerHTML = arc90_gtlt(o.alt);
					y.appendChild(z);
					s.appendChild(y);
				}
/*
				if (o.title != '') {
					x.innerHTML = arc90_gtlt(o.title);
					s.appendChild(x);
				}
*/
				o.parentNode.insertBefore(s, o);
				if (o.align=='middle') o.parentNode.insertBefore(clearer, o);
				o.parentNode.removeChild(o);
        
        var w;

				if (document.all || arc90_isSafari) {
					w = parseInt(I.offsetWidth);
					if (w != '')
						s.style.width = w +'px';
				} else {
					w = arc90_getStyle(I, 'width', 'width');
					if (w != '') {
						s.style.width = (parseInt(w)) + 'px';
						x.style.width = (parseInt(w)) + 'px';
						y.style.width = (parseInt(w)) + 'px';
					}
				}
				if (o.align=='middle') {
          s.style.marginLeft = Math.floor((647-parseInt(w))/2) + 'px';
        }
			} catch (err) { o = null; }
		}
	}
var O = document.getElementsByTagName('P'); // For safari???
for (i = 0, l = O.length; i < l; i++)
	O[i].appendChild(arc90_newNode('span'));
}

function arc90_gtlt(s) {
	s = s.replace(/&gt;/g, '>');
	s = s.replace(/&lt;/g, '<');
	return s;
}

function arc90_getStyle(obj, styleIE, styleMoz) {
	if (arc90_isString(obj)) obj = document.getElementById(obj);
	if (window.getComputedStyle)
		return document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleMoz);
	else if (obj.currentStyle)
		return obj.currentStyle[styleIE];
}

function arc90_findDimension(obj, pType) {
	if (arc90_isString(obj)) obj = document.getElementById(obj);
	var cur = 0;
	if(obj.offsetParent)
		while(obj.offsetParent) {
			switch(pType.toLowerCase()) {
			case "width":
				cur += obj.offsetWidth; break;
			case "height":
				cur += obj.offsetHeight; break;
			case "top":
				cur += obj.offsetTop; break;
			case "left":
				cur += obj.offsetLeft; break;
			}
			obj = obj.offsetParent;
		}
	return cur;
}

/* Events */
function arc90_isString(o) { return (typeof(o) == "string"); }

function arc90_addEvent(e, meth, func, cap) {
	if (arc90_isString(e))	e = document.getElementById(e);

	if (e.addEventListener){
		e.addEventListener(meth, func, cap);
    	return true;
	}	else if (e.attachEvent)
		return e.attachEvent("on"+ meth, func);
	return false;
}

/* Nodes */
function arc90_newNode(t, i, s, x, c) {
	var node = document.createElement(t);
	if (x != null && x != '') {
		var n = document.createTextNode(x);
		node.appendChild(n);
	}
	if (i != null && i != '')
		node.id = i;
	if (s != null && s != '')
		node.className = s;
	if (c != null && c != '')
		node.appendChild(c);
	return node;
}

// equalize column heights
function eq_col() {
	$('right_side').style.height = $('left_side').offsetHeight + "px";
}

var read_ss_img = 0;

function read_ss_next() 
{
  if (read_ss_img < read_ss_images.length-1) 
  {
    show_read_image(++read_ss_img);
  }
}

function read_ss_prev() 
{
  if (read_ss_img > 0) 
  {
    show_read_image(--read_ss_img);
  }
}

function show_read_image(i)
{
  var d = $('read_slide_show_c');
  new Effect.Opacity(d,
  {
      duration:.5,
      from:1.0,
      to:0,
      afterFinish: function() 
      {
      	$('read_slide_show_img').src = "/images/upload/" + read_ss_images[i][0];
        $('read_slide_show_caption').innerHTML = read_ss_images[i][2];
        $('read_slide_show_count').innerHTML = i+1;
        new Effect.Opacity(d,
        {
            delay: .5,
            duration:.5,
            from:0,
            to:1.0
        });
      }
  });
    
}

function submitfrm()
{
	document.frmSearch.submit();
}
function pop_scoop_login()
{
	window.open("/login.php", "Login", "status=0,height=300,width=400,resizable=1");
}

arc90_addEvent(window, 'load', eq_col);
