/* begin Page */

var artEventHelper = {
  'bind' : function (obj, evt, fn) {
    if (obj.addEventListener)
      obj.addEventListener(evt, fn, false);
    else if (obj.attachEvent)
      obj.attachEvent('on' + evt, fn);
    else
      obj['on' + evt] = fn;
  }
};

var artLoadEvent = (function() {
  var userAgent = navigator.userAgent.toLowerCase();
  var browser = {
    version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
    safari: /webkit/.test(userAgent),
    opera: /opera/.test(userAgent),
    msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
    mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
  };

  var list = [];

  var done = false;
  var ready = function () {
    if (done) return;
    done = true;
    for (var i = 0; i < list.length; i++)
      list[i]();
  };
  
  if (document.addEventListener && !browser.opera)
    document.addEventListener('DOMContentLoaded', ready, false);
  
  if (browser.msie && window == top) {
    (function () {
      try {
        document.documentElement.doScroll('left');
      } catch (e) {
        setTimeout(arguments.callee, 10);
        return;
      }
      ready();
    })();
  }
  
  if (browser.opera) {
    document.addEventListener('DOMContentLoaded', function () {
      for (var i = 0; i < document.styleSheets.length; i++) {
        if (document.styleSheets[i].disabled) {
          setTimeout(arguments.callee, 10);
          return;
        }
      }
      ready();
    }, false);
  }
  
  if (browser.safari) {
    var numStyles;
    (function(){
      if (document.readyState != 'loaded' && document.readyState != 'complete') {
        setTimeout(arguments.callee, 10);
        return;
      }
      if ('undefined' == typeof numStyles) {
        numStyles = document.getElementsByTagName('style').length;
        var links = document.getElementsByTagName('link');
        for (var i = 0; i < links.length; i++) {
          numStyles += (links[i].getAttribute('rel') == 'stylesheet') ? 1 : 0;
        }
        if (document.styleSheets.length != numStyles) {
          setTimeout(arguments.callee, 0);
          return;
        }
      }
      ready();
    })();
  }

  artEventHelper.bind(window, 'load', ready);

  return ({
    add: function(f) {
      list.push(f);
    }
  })
})();

(function () {
  // fix ie blinking
  var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
  try{ if(!!m) { m("BackgroundImageCache", false, true); } }
  catch(oh){};
})();

function xGetElementsByClassName(clsName, parentEle, tagName) {
  var elements = null;
  var found = [];
  var slash = String.fromCharCode(92);
  var re = new RegExp(slash + "b" + clsName + slash + "b");
  if (!parentEle) parentEle = document;
  if (!tagName) tagName = '*';
  elements = parentEle.getElementsByTagName(tagName);
  if (elements) {
    for (var i = 0; i < elements.length; ++i) {
      if (elements[i].className.search(re) != -1) {
        found[found.length] = elements[i];
      }
    }
  }
  return found;
}

var styleUrlCached = null;
function GetStyleUrl() {
  if (null == styleUrlCached) {
    var ns;
    styleUrlCached = '';
    ns = document.getElementsByTagName('link');
    for (var i = 0; i < ns.length; i++) {
      var l = ns[i];
      if (l.href && /style\.css(\?.*)?$/.test(l.href)){
        return styleUrlCached = l.href.replace(/style\.css(\?.*)?$/,'');
      }
    }
    
    ns = document.getElementsByTagName('style');
    for (var i = 0; i < ns.length; i++) {
      var matches = new RegExp('import\\s+"([^"]+\\/)style\\.css"').exec(ns[i].innerHTML);
      if (null != matches && matches.length > 0)
        return styleUrlCached = matches[1];
    }
  }
  return styleUrlCached;
}


function artButtonSetupJsHover(btn)
{
    artEventHelper.bind(btn, 'mouseover', function() {
        var spans = btn.getElementsByTagName("span");
        if (spans.length > 0)
            spans[0].className += " hover";
    });
    artEventHelper.bind(btn, 'mouseout', function() {
        var spans = btn.getElementsByTagName("span");
        if (spans.length > 0)
            spans[0].className = spans[0].className.replace(/hover/, "").replace(/active/, "");
    });
    artEventHelper.bind(btn, 'mousedown', function() {
        var spans = btn.getElementsByTagName("span");
        if (spans.length > 0)
            spans[0].className += " active";
    });
    artEventHelper.bind(btn, 'mouseup', function() {
        var spans = btn.getElementsByTagName("span");
        if (spans.length > 0)
            spans[0].className = spans[0].className.replace(/active/, "");
    });
}

function artButtonsSetupJsHover() {
  var elements = xGetElementsByClassName("btn", document, "span");
  for (var i = 0; i < elements.length; i++) {
    if (!elements[i].tagName) continue;
    artButtonSetupJsHover(elements[i].parentNode);
  }
}
artLoadEvent.add(artButtonsSetupJsHover);

/* end Page */

/* begin Menu */
function Insert_Separators()
{
  var menus = xGetElementsByClassName("artmenu", document);
  for (var i = 0; i < menus.length; i++) {
    var menu = menus[i];
    var childs = menu.childNodes;
    var listItems = [];
    for (var j = 0; j < childs.length; j++){
      var el = childs[j];
      if (String(el.tagName).toLowerCase() == "li")listItems.push(el);
    }
    for (var j = 0; j < listItems.length - 1; j++){
      var span = document.createElement('span');
      span.className = 'separator';
      var li = document.createElement('li');
      li.appendChild(span);
      listItems[j].parentNode.insertBefore(li, listItems[j].nextSibling);
    }
  }
}
artLoadEvent.add(Insert_Separators);

function Menu_IE6Setup() {
  var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie") != -1 
    && navigator.userAgent.toLowerCase().indexOf("msie 7") == -1;
  if (!isIE6) return;
  var aTmp2, i, j, oLI, aUL, aA;
  var aTmp = xGetElementsByClassName("artmenu", document, "ul");
  for (i=0;i<aTmp.length;i++) {
    aTmp2 = aTmp[i].getElementsByTagName("li");
    for (j=0;j<aTmp2.length;j++) {
      oLI = aTmp2[j];
      aUL = oLI.getElementsByTagName("ul");
      if (aUL && aUL.length) {
        oLI.UL = aUL[0];
        aA = oLI.getElementsByTagName("a");
        if (aA && aA.length)
        	oLI.A = aA[0];
         oLI.onmouseenter = function() {
         	this.className += " artmenuhover";
         	this.UL.className += " artmenuhoverUL";
         	if (this.A) this.A.className += " artmenuhoverA";
         };
        oLI.onmouseleave = function() {
          this.className = this.className.replace(/artmenuhover/,"");
          this.UL.className = this.UL.className.replace(/artmenuhoverUL/,"");
          if (this.A) this.A.className = this.A.className.replace(/artmenuhoverA/, "");
        };
      }
    }
  }
}
artLoadEvent.add(Menu_IE6Setup);
/* end Menu */

/* begin wp-polls */

/*
+----------------------------------------------------------------+
|																							|
|	WordPress 2.8 Plugin: WP-Polls 2.61										|
|	Copyright (c) 2009 Lester "GaMerZ" Chan									|
|																							|
|	File Written By:																	|
|	- Lester "GaMerZ" Chan															|
|	- http://lesterchan.net															|
|																							|
|	File Information:																	|
|	- Polls Javascript File															|
|	- wp-content/plugins/wp-polls/polls-js.js									|
|																							|
+----------------------------------------------------------------+
*/


// Variables
var poll_id = 0;
var poll_answer_id = '';
var is_being_voted = false;
pollsL10n.show_loading = parseInt(pollsL10n.show_loading);
pollsL10n.show_fading = parseInt(pollsL10n.show_fading);

// When User Vote For Poll 
function poll_vote(current_poll_id) {
	if(!is_being_voted) {
		set_is_being_voted(true);
		poll_id = current_poll_id;
		poll_answer_id = '';
		poll_multiple_ans = 0;
		poll_multiple_ans_count = 0;
		if(jQuery('#poll_multiple_ans_' + poll_id).length) {
			poll_multiple_ans = parseInt(jQuery('#poll_multiple_ans_' + poll_id).val());
		}
		jQuery('#polls_form_' + poll_id + ' input:checkbox, #polls_form_' + poll_id + ' input:radio').each(function(i){
			if (jQuery(this).is(':checked')) {					
				if(poll_multiple_ans > 0) {
					poll_answer_id = jQuery(this).val() + ',' + poll_answer_id;
					poll_multiple_ans_count++;
				} else {
					poll_answer_id = parseInt(jQuery(this).val());
				}
			}
		});
		if(poll_multiple_ans > 0) {
			if(poll_multiple_ans_count > 0 && poll_multiple_ans_count <= poll_multiple_ans) {
				poll_answer_id = poll_answer_id.substring(0, (poll_answer_id.length-1));
				poll_process();
			} else if(poll_multiple_ans_count == 0) {
				set_is_being_voted(false);
				alert(pollsL10n.text_valid);
			} else {
				set_is_being_voted(false);
				alert(pollsL10n.text_multiple + ' ' + poll_multiple_ans);
			}
		} else {
			if(poll_answer_id > 0) {
				poll_process();
			} else {
				set_is_being_voted(false);
				alert(pollsL10n.text_valid);
			}
		}
	} else {
		alert(pollsL10n.text_wait);
	}
}

// Process Poll (User Click "Vote" Button)
function poll_process() {
	if(pollsL10n.show_fading) {
		jQuery('#polls-' + poll_id).fadeTo('def', 0, function () {
			if(pollsL10n.show_loading) {
				jQuery('#polls-' + poll_id + '-loading').show();
			}
			jQuery.ajax({type: 'POST', url: pollsL10n.ajax_url, data: 'vote=true&poll_id=' + poll_id + '&poll_' + poll_id + '=' + poll_answer_id, cache: false, success: poll_process_success});
		});
	} else {
		if(pollsL10n.show_loading) {
			jQuery('#polls-' + poll_id + '-loading').show();
		}
		jQuery.ajax({type: 'POST', url: pollsL10n.ajax_url, data: 'vote=true&poll_id=' + poll_id + '&poll_' + poll_id + '=' + poll_answer_id, cache: false, success: poll_process_success});
	}
}

// Poll's Result (User Click "View Results" Link)
function poll_result(current_poll_id) {
	if(!is_being_voted) {
		set_is_being_voted(true);
		poll_id = current_poll_id;
		if(pollsL10n.show_fading) {
			jQuery('#polls-' + poll_id).fadeTo('def', 0, function () {
				if(pollsL10n.show_loading) {
					jQuery('#polls-' + poll_id + '-loading').show();
				}
				jQuery.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'pollresult=' + poll_id, cache: false, success: poll_process_success});
			});
		} else {
			if(pollsL10n.show_loading) {
				jQuery('#polls-' + poll_id + '-loading').show();
			}
			jQuery.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'pollresult=' + poll_id, cache: false, success: poll_process_success});
		}
	} else {
		alert(pollsL10n.text_wait);
	}
}

// Poll's Voting Booth  (User Click "Vote" Link)
function poll_booth(current_poll_id) {
	if(!is_being_voted) {
		set_is_being_voted(true);
		poll_id = current_poll_id;
		if(pollsL10n.show_fading) {
			jQuery('#polls-' + poll_id).fadeTo('def', 0, function () {
				if(pollsL10n.show_loading) {
					jQuery('#polls-' + poll_id + '-loading').show();
				}
				jQuery.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'pollbooth=' + poll_id, cache: false, success: poll_process_success});
			});
		} else {
			if(pollsL10n.show_loading) {
				jQuery('#polls-' + poll_id + '-loading').show();
			}
			jQuery.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'pollbooth=' + poll_id, cache: false, success: poll_process_success});
		}
	} else {
		alert(pollsL10n.text_wait);
	}
}

// Poll Process Successfully
function poll_process_success(data) {
	jQuery('#polls-' + poll_id).replaceWith(data);
	if(pollsL10n.show_loading) {
		jQuery('#polls-' + poll_id + '-loading').hide();
	}
	if(pollsL10n.show_fading) {
		jQuery('#polls-' + poll_id).fadeTo('def', 1, function () {		
			set_is_being_voted(false);	
		});
	} else {
		set_is_being_voted(false);	
	}
}

// Set is_being_voted Status
function set_is_being_voted(voted_status) {
	is_being_voted = voted_status;
}

/* end wp-polls */

