/* base JS stuff */

jQuery(function() { // fire on DOM-ready
	jQuery('#product-details-media img').hover(
		function() {
			jQuery(this).addClass('cursorZoom');
		}, function() {
			jQuery(this).removeClass('cursorZoom');
		}
	);

	jQuery('#product-details-media .video-thickbox').click(function() {
		tb_window();
	});




	jQuery('.product-list-videoplayer-iframe').click(function() {
		strIFrameNumber = parseInt(jQuery(this).attr('name').substr(-1));
		parent.frames[strIFrameNumber].sendToNonverBlaster('stop');
		console.log(jQuery(this).attr('id') + ' clicked.');
	}).hover(function() {
		strIFrameNumber = parseInt(jQuery(this).attr('name').substr(-1));
		parent.frames[strIFrameNumber].sendToNonverBlaster('play');

	}, function() {

		strIFrameNumber = parseInt(jQuery(this).attr('name').substr(-1));
		parent.frames[strIFrameNumber].sendToNonverBlaster('pause');
	});


	jQuery('a[href=#tabnav]').click(function() {
		return false;
	});



});

/**
 * function parseQuery
 *
 * @description Parses the GET query into an associative array
 * @parameter string Query
 * @return array ParsedQuery Consists of ParsedQuery[varName] = varValue;
 */

function parseQueryAssoc(strUserQuery) {
	returnData = new Object();
	strQueryString = strUserQuery;

	if(strUserQuery.substr(0, 1) == '?') {
		strQueryString = strUserQuery.substr(1);
	}

	if(strQueryString != '') {
		arrX = strQueryString.split('&');

		for(n = 0; n < arrX.length; n++) {
			arrX2 = arrX[n].split('=');
			returnData[arrX2[0]] =  arrX2[1];
		}

	}


	return returnData;
}

function checkCurrentlySelectedCategory(iCheckID) {
	QueryString = parseQueryAssoc(window.location.search);

	if(QueryString.cat == '') { // no category set
		strHomeLinkHref = jQuery('.sidebar-link-home a').attr('href');
		if(strHomeLinkHref.search("cat=") > -1) {
			jQuery('.sidebar-link-home a').attr('href', strHomeLinkHref + iCheckID);
		}
	}
}

