/*
** Stoneply.com general functionality and utilities
** Last Updated: 10/14/2010
*/

;if(typeof(stoneply) == "undefined") { var stoneply = {}; }

stoneply.stoneSelect = (function(){
	var _config = {
		url: '/includes/stoneselect_proc.php'
	};
	var _cache = {};
	
	var _private = {};
	var _public = {};
	
	_private.bindEvents = function(){
		jQuery('#stone_select select[name=stone_color], #stone_select select[name=stone_type]').change(function(){
			_private.repopulate(this);
		});
	};
	
	_private.repopulate = function(obj){
		var value = obj[obj.selectedIndex].value;
		if(obj.name == "stone_color") {
			action = 'repopType';
			//jQuery('#stone_select select[name=stone_type]').load(_config.url + "?a=" + action + "&v=" + value);
			console.log(_config.url); /*
			jQuery.ajax({
				url: _config.url,
				type: "POST",
				data: 'a=' + action + '&v=' + value,
				success: function(data, status, xmlobj) {
					console.log(data);
					console.log(status);
					console.log(xmlobj);
				},
				error: function(xmlobj, status, error) {
					console.log("error thrown: ");
					console.log(error);
					console.log(status);
					console.log(xmlobj);
				}
			}); // */
			jQuery.get(_config.url + 'a=' + action + '&v=' + value, function(data) {
				console.log(data);
			}); // */
		} else if(obj.name == "stone_type") {
			action = 'repopColor';
			//jQuery('#stone_select select[name=stone_color]').load(_config.url, {'a': action, 'v': value});
		}
		//console.log(_config.url + '?a=' + action + '&v=' + value);
	};
	
	_public.init = function(){
		_private.bindEvents();
		
		
	};
	
	return _public;
})();

function loadImage(obj, status) {
	val = (status==1) ? 'active' : 'normal';
	
	document.getElementById(obj.id).setAttribute('class', val);
}

function simplePreload() {	
	var args = simplePreload.arguments;
	
	document.imageArray = new Array(args.length);	
	for(var i=0; i<args.length; i++) {	
		document.imageArray[i] = new Image;	
		document.imageArray[i].src = args[i];	
	}	
}

function showContent(val) {
	var ids = new Array();
	ids[0] = 'specialty_yachts';
	ids[1] = 'specialty_aircraft';
	ids[2] = 'specialty_signage';
	ids[3] = 'specialty_furniture';
	
	for(i=0; i<4; i++) {
		var x = (ids[i]==val) ? 'block' :  'none';
		
		document.getElementById(ids[i]).style.display = x;
	}
}


jQuery(document).ready(function(){
	stoneply.stoneSelect.init();
});
