// JavaScript Document

	jQuery.noConflict( );

//Load Functions

jQuery('document').ready(function() {


	jQuery('#sidebar img').click(function(){

		switch (jQuery(this).attr("id")) {

			case "shopButton" : 
				if (shopPanel.isOpen()) { changeMainContent('#default'); }
				else {
					changeMainContent('#cards'); 
			    	if (dsKeywords.getDataWasLoaded()) { FilterData(0); }
			    	else {setTimeout("FilterData(0)" , 5000);}
				}
			break;
		}
		
			
	
	});
	
		jQuery('#contact #telephone').click(function() {
				var vw = jQuery('#voiceWidget');
				var link = jQuery('#telephone');
				link.hide("slow");
				vw.hide();
				vw.css({'left' : 5, 'top' : 10, 'position' : 'relative'});
				vw.slideDown();
		});

	
	jQuery('#mainContent').children().eq(0).fadeIn("slow");
	if (window.location.href == "http://www.hardcardsrule.com/index.php")
		{ showDefault(); }
		
	jQuery('#sidebar').fadeIn(7000);
	

});
/*
function toggleSelect() {

		jQuery('#sidebar li').each(function(){ 
			jQuery(this).removeClass('selected'); 
		}); //close each
		
		jQuery(this).addClass('selected');

}
*/
function showDefault () {

//	jQuery('#layer1').html("<img src=\"images/default/giftSelfEsteem.jpg\" alt=\"Gift Self Esteem\" />").show("slow");
//	jQuery('#layer2').html("<img src=\"images/default/weddingPrenup.jpg\" alt=\"Borthday Porn\" />");
//	jQuery('#layer3').html("<img src=\"images/default/loveYouDesperate.jpg\" alt=\"Love You Desperate\" />");
//	jQuery('#layer4').html("<img src=\"images/default/youreSoHot.jpg\" alt=\"You\'re So Hot\" />");
//	jQuery('#layer5').html("<img src=\"images/default/honesty.jpg\" alt=\"Honesty\" />");
//	jQuery('#layer6').html("<img src=\"images/default/throwStones.jpg\" alt=\"Throw Stones\" />");
//	jQuery('#layer7').html("<img src=\"images/default/congratsBitter.jpg\" alt=\"Congrats Bitter\" />");	
		
}


function changeMainContent (selected) {
		jQuery(selected).siblings().filter("div").hide();
		jQuery(selected).fadeIn("slow");
}

function FilterData(rowNum)	{

	dsKeywords.setCurrentRow(rowNum)
	
	var keywordRow = dsKeywords.getCurrentRowID();
	var param = keywordRow;
	
	
//	alert( 'keyword row is ' + keywordRow + '. the parameter is ' + param);

/*	 turned this off because of row 0 returning false

	if (!keywordRow)
	{
		// If the text field is empty, remove any filter
		// that is set on the data set.

		dsProducts.filter(null);
		return;
	}
*/

	// Set a filter on the data set that matches any row
	// that begins with the string in the text field.


	
	var filterFunc = function(ds, row, rowNumber)
		{
			var str = row["keywordId"];
			if (str && str == param)
				return row;
				return;
		};
	
		dsProducts.filter(filterFunc);
		dsProducts.setCurrentRowNumber(0);
		dsPhotoView.setCurrentRowNumber(0);
	
//make sure the cards layer is showing	
	
	
}

