
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function trim(str) {  
	while(str.charAt(0) == (" ")) {
		str = str.substring(1);
	}
	while(str.charAt(str.length-1) == " ") { 
		str = str.substring(0,str.length-1);
	}
	return str;
}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var Char;
	for (var i = 0; i < sText.length; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			return false;
		}
	}
	return true;
}

function createRequestObject() {
    var request_object;
    if (window.ActiveXObject) {
        request_object = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        request_object = new XMLHttpRequest();
    }
    return request_object;
}

addLoadEvent(prepare_search_bar);

function prepare_search_bar() {
	if (!document.getElementById) return false;
	if (!document.getElementById('search_bar_input')) return false;
	var search_bar = document.getElementById('search_bar_input');
	search_bar.onfocus = function() {
		clear_search();
		return false;
	}
	search_bar.onblur = function() {
		check_search();
		return false;
	}
}

function clear_search() {
	var search_bar = document.getElementById('search_bar_input');
	if (search_bar.value == 'Product Search') {
		search_bar.value = '';
		search_bar.style.color = '#000';		
	}
}

function check_search() {
	var search_bar = document.getElementById('search_bar_input');
	if (trim(search_bar.value) == '') {
		search_bar.style.color = '#c0c0c0';
		search_bar.value = 'Product Search';
	}
}

addLoadEvent(prepare_search_bar_two);

function prepare_search_bar_two() {
	if (!document.getElementById) return false;
	if (!document.getElementById('search_bar_input_two')) return false;
	var search_bar_two = document.getElementById('search_bar_input_two');
	search_bar_two.onfocus = function() {
		clear_search_two();
		return false;
	}
	search_bar_two.onblur = function() {
		check_search_two();
		return false;
	}
}

function clear_search_two() {
	var search_bar_two = document.getElementById('search_bar_input_two');
	if (search_bar_two.value == 'Search News Archive') {
		search_bar_two.value = '';
		search_bar_two.style.color = '#000';		
	}
}

function check_search_two() {
	var search_bar_two = document.getElementById('search_bar_input_two');
	if (trim(search_bar_two.value) == '') {
		search_bar_two.style.color = '#c0c0c0';
		search_bar_two.value = 'Search News Archive';
	}
}

addLoadEvent(prepare_newsletter_email);

function prepare_newsletter_email() {
	if (!document.getElementById) return false;
	if (!document.getElementById('newsletter_email')) return false;
	var email = document.getElementById('newsletter_email');
	email.onfocus = function() {
		clear_email();
		return false;
	}
	email.onblur = function() {
		check_email();
		return false;
	}
}

function clear_email() {
	var email = document.getElementById('newsletter_email');
	if (email.value == 'Email Address') {
		email.value = '';
		email.style.color = '#000';		
	}
}

function check_email() {
	var email = document.getElementById('newsletter_email');
	if (trim(email.value) == '') {
		email.style.color = '#c0c0c0';
		email.value = 'Email Address';
	}
}

addLoadEvent(prepare_buttons);

function prepare_buttons() {
	if (!document.getElementsByTagName) return false;
	var inputs = document.getElementsByTagName('img');
	for (var i=0; i<inputs.length; i++) {
		if (inputs[i].className == 'hover') {
			inputs[i].onmouseover = function() {
				hover_image(this);
				return false;
			}
			inputs[i].onmouseout = function() {
				return_image(this);
				return false;
			}
		}
	}
	var inputs = document.getElementsByTagName('input');
	for (var i=0; i<inputs.length; i++) {
		if (inputs[i].className == 'hover') {
			inputs[i].onmouseover = function() {
				hover_image(this);
				return false;
			}
			inputs[i].onmouseout = function() {
				return_image(this);
				return false;
			}
		}
	}
}


function hover_image(obj) {
	var last = obj.src.lastIndexOf('.');
	var image = obj.src.substring(0, last);
	var type = obj.src.substring(last, obj.src.length);
	obj.src = image+'_on'+type;
}

function return_image(obj) {
	var last = obj.src.lastIndexOf('.');
	var image = obj.src.substring(0, last);
	var type = obj.src.substring(last, obj.src.length);
	last = image.lastIndexOf('_');
	orig = image.substring(0, last);
	obj.src = orig+type;
}


//window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init()
{
	if(!d.getElementById || !d.createElement)return false;
	if (!document.getElementById('front_page_featured')) return false;
	css = d.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);

	imgs = d.getElementById('front_page_featured').getElementsByTagName('img');
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;

	setTimeout(so_xfade,10000);
}

function so_xfade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}


function do_link () {
	var text = prompt ("Enter link text (optional)", "");
	var url = prompt ("Enter URL", "http://");
	if (text == '')
		text = url;
	if (url != '' && url != 'http://' && url != 'null') 
		insertText(document.getElementById('text_area'), '', '', '<a href="' + url + '">'+text+'</a>');
}

function do_bold () {
	insertText(document.getElementById('text_area'), '<strong>', '</strong>', '');
}

function do_italic () {
	insertText(document.getElementById('text_area'), '<em>', '</em>', '');
}

function do_blockquote () {
	insertText(document.getElementById('text_area'), '<blockquote class="news_quote">', '</blockquote>', '');
}

function do_h2 () {
	insertText(document.getElementById('text_area'), '<div class="dashed_news_container"><b class="news_bold_two">', '</b></div>', '');
}

function do_h3 () {
	insertText(document.getElementById('text_area'), '<b class="news_bold_one">', '</b>', '');
}

function insertText(myField, tagStart, tagEnd, myValue) {

	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		if (sel.text.length > 0) {
			if (myValue != '') 
				sel.text = myValue;
			else 
				sel.text = tagStart + sel.text + tagEnd;
		}
		else {
			if (myValue != '') 
				sel.text = myValue;
			else  {
				sel.text = tagStart;
				sel.text = tagEnd;
			}
		}
		myField.focus();
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		var cursorPos = endPos;
		var scrollTop = myField.scrollTop;
		if (startPos != endPos) {
			if (myValue != '') {
				myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
				cursorPos += myValue.legth;
			} else {
				myField.value = myField.value.substring(0, startPos) + tagStart + myField.value.substring(startPos, endPos) + tagEnd+ myField.value.substring(endPos, myField.value.length);
				cursorPos += tagStart.length + tagEnd.length;
			}
			
		}
		else {
			if (myValue != '') {
				myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
				cursorPos = startPos + myValue.length;
			} else {
				myField.value = myField.value.substring(0, startPos) + tagStart + tagEnd + myField.value.substring(endPos, myField.value.length);
				cursorPos = startPos + tagStart.length;
			}
		}
		myField.focus();
		myField.selectionStart = cursorPos;
		myField.selectionEnd = cursorPos;
		myField.scrollTop = scrollTop;
	}
	else {
		if (myValue != '') {
			myField.value += myValue;
		} else {
			myField.value += tagStart;
			myField.value += tagEnd;
		}
		myField.focus();
	}
}

function prepareToolBar() {
	if (!document.getElementById) return false;
	if (!document.getElementById('tool_bar')) return false;
	if (!document.getElementById('text_area')) return false;
	if (document.getElementById('toolbar_link')) {
		document.getElementById('toolbar_link').onclick = function() {
			do_link();
			return false;
		}
	}
	if (document.getElementById('toolbar_bold')) {
		document.getElementById('toolbar_bold').onclick = function() {
			do_bold();
			return false;
		}
	}
	if (document.getElementById('toolbar_italic')) {
		document.getElementById('toolbar_italic').onclick = function() {
			do_italic();
			return false;
		}
	}
	if (document.getElementById('toolbar_blockquote')) {
		document.getElementById('toolbar_blockquote').onclick = function() {
			do_blockquote();
			return false;
		}
	}
	if (document.getElementById('toolbar_h2')) {
		document.getElementById('toolbar_h2').onclick = function() {
			do_h2();
			return false;
		}
	}
	if (document.getElementById('toolbar_h3')) {
		document.getElementById('toolbar_h3').onclick = function() {
			do_h3();
			return false;
		}
	}
}


function toggle_reviews(id) {
       var e = document.getElementById(id);
	   
       if(e.style.display == 'block'){
          e.style.display = 'none';
	   } else {
          e.style.display = 'block';
	   }
}

//addLoadEvent(toggle_reviews);

























































































