/*
+------------------------------------------------------------------------------------------+
* COMPANY: Raven Developers 2009
+------------------------------------------------------------------------------------------+
* FILE INFO: Site wide Java Script functions
+------------------------------------------------------------------------------------------+
* WEBSITE: http://www.ravendevelopers.com
+------------------------------------------------------------------------------------------+
* Portions created by Anirudh K. Mahant are Copyright of Raven Developers (C) 2009.
+------------------------------------------------------------------------------------------+
* COPYRIGHT NOTICE:
* The original author(s) retain all the copyrights of this file.
* Portions created by Anirudh K. Mahant (original developer) are Copyright of Raven Developers (C) 2009.
* Portions may contain jQuery JavaScript framework developed by John Resig and other
* community members. More info at http://docs.jquery.com/About
* jQuery LICENSE:
* Copyright (c) 2008 John Resig (jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
+------------------------------------------------------------------------------------------+
*/
function URLDecode(psEncodeString){
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
//-- Creates and applies Zebra tables alternating rows to tables with Class name .zebra-tbl automatically
//-- from there you can define the CSS styling for each rows cell :) Simple but effective solution!
function ZebraTables(){
	theTable = jQuery.find("table.zebra-table");
	jQuery(theTable).each(function(i){
		if (this){
			jQuery(this).find("tr").each(function(i){
				var zclass = (i%2 == 0) ? 'odd' : 'even';
				jQuery(this).addClass(zclass);
			});
		}
	});
}
//-- Creates and applies Zebra tables alternating rows to Unordered Lists with Class name .zebra-tbl automatically
//-- from there you can define the CSS styling for each rows cell :) Simple but effective solution!
function ZebraUL(){
	theUL = jQuery(document).find("ul.zebra-ul");
	jQuery(theUL).each(function(i){
		if (this){
		 jQuery(this).find("li").each(function(i){
			// var zclass = (i%1 == 0) ? 'odd' : 'even';
			 //jQuery(this).addClass(zclass);
		 });
		}
	});
}
//-- Order Form Tabs
function OrderTabs(){
	/*jQuery(document).find("div.order-tabs ul li a").each(function(i){
		jQuery(this).removeClass()
	});*/
	jQuery("div.order-tabs ul li a").click(function(){
		theRel = jQuery(this).attr('rel');
		jQuery(this).addClass(theRel + '-active');
		var arrayOfRel = theRel.split('-');
		var theTabs = jQuery("div.order-tabs");
		jQuery(theTabs).removeAttr("class");
		jQuery(theTabs).attr("class", "order-tabs outline-none");
		jQuery("div.order-tabs").addClass("bg-" + arrayOfRel[1]);
		jQuery(document).find("div.sections").each(function(i){
			var arrayOfClasses = jQuery(this).attr('class').split(' ');
			if (arrayOfClasses[0] != theRel){
				jQuery(this).hide();
			} else {
				jQuery(this).show();
			}
		});
	});
}
jQuery(document).ready(function(){
	//Site wide JS code here
	ZebraTables();
	ZebraUL();
	OrderTabs();
});