﻿
/* Populate/Clear the Search Box Field */

function clearText(val) {
	if (val.value == "Search")
		val.value = "";
}

function showText(val) {
	if (val.value.length < 1)
		val.value = "Search";
}

/* Layer Swaps */
function swapLayer(parentDiv, val, val2) {
	var allDivs = document.getElementById(parentDiv);
	var divArray = allDivs.getElementsByTagName('div');
	for (var i = 0; i < divArray.length; ++i) {
		if ((divArray[i].id == val) || (divArray[i].id == val2)) {
			document.getElementById(divArray[i].id).style.display = 'block';
		}
		else {
			document.getElementById(divArray[i].id).style.display = 'none';
		}
	}
}

function toggleButton(parentDiv, val) {
	var allDivs = document.getElementById(parentDiv);
	var divArray = allDivs.getElementsByTagName('div');
	for (var i = 0; i < divArray.length; ++i) {
		if (divArray[i].id == val) {
			document.getElementById(divArray[i].id).getElementsByTagName('a')[0].style.backgroundPosition = 'bottom left';
		}
		else {
			document.getElementById(divArray[i].id).getElementsByTagName('a')[0].style.backgroundPosition = 'top left';
		}
	}
}

/* Open a new window (perfectly centered at 70-90% of screen size) */
function openWin() {
	args = openWin.arguments;

	/*--- Choose window size (full screen minus how many pixels) ---*/
	var windowsize = 150;
	/*--------------------------------------------------------------*/

	var width = screen.width - windowsize;
	var height = screen.height - (windowsize * 2);
	var widthc = windowsize / 2;
	var heightc = windowsize / 2;
	window.open(args[0], 'openWin', 'width=' + width + ',height=' + height + ',top=' + heightc + ',left=' + widthc + ',scrollbars=1,status=1,toolbar=1,menubar=1,resizable=1');
	return false;
}


/*--------------------------- Added by Simpleflame on 12/27/2011 -----------------------------------*/


/*
 $(document).ready(function() {
	
	// $('.stock select').each(function(i, select){
	$('.stock').each(function(){
		var $select = $(this).find("select");
		
		// define parentNode
		$(this).find("strong").attr("id",$select.attr("id"));
		
		$select.find('option').each(function(j, option){
			var $option = $(option);
			// Create a radio:
			var $radio = $('<input type="radio" />');
			var uniqueID = $select.attr("id");
			

			
			// Set OnChange
			$radio.attr('onclick', $select.attr('onchange'));
			
			// Set name and value:
			$radio.attr('name', $select.attr('id')+"-"+$select.attr('name')).attr('value', $option.val());
			
			// Set checked if the option was selected
			if ($option.attr('selected')) $radio.attr('checked', 'checked');
			
			// Insert radio before select box:
			$select.before($radio);
			
			// Insert a label:
			$select.before(
			  $("<label />").attr('for', $select.attr('name')).text($option.text())
			);
			
			// Insert a <br />:
			$select.before("<br/>");
    });
    $select.remove();
}); 

	
});

*/

	

