jQuery.noConflict();
function slideFrame(thumbid, move_by, direction, type, match_height)
	{
		/* Set the new position & frame number */
		frame_left = jQuery(thumbid).css(type).replace("px", "");
		frame_no = (-(frame_left/move_by));
		maxsize = (jQuery(thumbid).children("li").size()-1);
		if(direction == 0)
			{
				new_frame_no =  Math.round((frame_no/1)+1);
				
				if(jQuery.browser.msie)
					maxsize = (maxsize-1);
					
				if(maxsize <= frame_no)
					new_frame_no = 0;
				new_left = -(new_frame_no*move_by)+"px";
			}
		else
			{
				new_frame_no = Math.round((frame_no/1)-1);
				
				new_left = -(new_frame_no*move_by)+"px";
			}
		if(type == "left")
			{jQuery(thumbid).animate({"left": new_left}, {duration: 500});}
		else
			{jQuery(thumbid).animate({"top": new_left}, {duration: 300});}
	}
jQuery(document).ready(function()
	{
		jQuery.noslide = 0;
		
		if(!jQuery.browser.msie){
			move_by = 940;
		} else {
			move_by = 1100;
		}

		if(document.getElementById("slider") && jQuery("#slider").children("li").size() > 1){
			setInterval(function(){
				if(jQuery.noslide == 0)
					{
						jQuery.noslide = 1;
						thumbid = "#slider";
											
						setTimeout(function(){
							if(!jQuery.browser.msie){
								startli = jQuery(thumbid).children("li:first");			
								startli.insertAfter(jQuery(thumbid).children("li:last")).fadeIn();
							}
							maxsize = (jQuery(thumbid).children("li").size()-1);
							frame_left = ((jQuery(thumbid).css("marginLeft").replace("px", "")/1)+move_by);
							frame_no = (frame_left/move_by);
							
							if(maxsize < frame_no){
								frame_left = 0;
							}
							
							if(!jQuery.browser.msie){
								jQuery(thumbid).css("marginLeft", frame_left);
							}
							setTimeout(function(){jQuery.noslide = 0;}, 200);
						}, 200);
						slideFrame(thumbid, move_by, 0, "left");
					}
				return false;
			
			}, 6000);
		};
		
		jQuery("#feature-next").live("click", function(){
			
			if(jQuery.noslide == 0)
				{
					jQuery.noslide = 1;
					thumbid = "#slider";
										
					setTimeout(function(){
						if(!jQuery.browser.msie){
							startli = jQuery(thumbid).children("li:first");			
							startli.insertAfter(jQuery(thumbid).children("li:last")).fadeIn();
						}
						maxsize = (jQuery(thumbid).children("li").size()-1);
						frame_left = ((jQuery(thumbid).css("marginLeft").replace("px", "")/1)+move_by);
						frame_no = (frame_left/move_by);
						
						if(maxsize < frame_no){
							frame_left = 0;
						}
							
							if(!jQuery.browser.msie){
								jQuery(thumbid).css("marginLeft", frame_left);
							}
						setTimeout(function(){jQuery.noslide = 0;}, 200);
					}, 200);
					slideFrame(thumbid, move_by, 0, "left");
				}
			return false;
		});
			
		jQuery("#feature-previous").live("click", function(){
			if(jQuery.noslide == 0)
				{
					jQuery.noslide = 1;
					move_by = 940;
					thumbid = "#feature-slider";
								
					setTimeout(function(){
						endli = jQuery(thumbid).children("li:last");
						endli.fadeOut("slow").insertBefore(jQuery(thumbid).children("li:first")).fadeIn();
						frame_left = (jQuery(thumbid).css("marginLeft").replace("px", "")-move_by);
						jQuery(thumbid).css("marginLeft", frame_left);
						setTimeout(function(){jQuery.noslide = 0;}, 200);
					}, 200);
					
					slideFrame(thumbid, 940, 1, "left");
				}
			return false;
		});
		
		
		/* jQuery(".column .sub-menu > li > a").click(function(){
			jQuery(".column .sub-menu ul").slideUp();
			jQuery(this).parent().children().slideDown().addClass("active");
			return false;
		}); */
		
		jQuery(".column .sub-menu li a").click(function(){			
			return true;
		});
	
		
		if(jQuery.browser.msie || jQuery.browser.mozilla)
			{Screen = jQuery("html");}
		else
			{Screen = jQuery("body");}
			
		jQuery.producttab = jQuery(".product-item-tabs li.selected a").attr("rel");
		jQuery(".product-item-tabs li a").click(function(){
			jQuery(".product-item-tabs li.selected").removeClass("selected");
			jQuery(this).parent().addClass("selected");
			tab = jQuery(this).attr("rel");
			jQuery(jQuery.producttab).slideUp();
			jQuery(tab).slideDown();
			jQuery.producttab = tab;
			return false;
		});
		jQuery.channproducttab = jQuery(".stats-tabs.statistics li.selected a").attr("rel");
		jQuery(".stats-tabs.statistics li a").click(function(){
			jQuery(".stats-tabs.statistics li.selected").removeClass("selected");
			jQuery(this).parent().addClass("selected");
			tab = jQuery(this).attr("rel");
			jQuery(jQuery.channproducttab).slideUp();
			jQuery(tab).slideDown();
			jQuery.channproducttab = tab;
			return false;
		});
		
		jQuery.demotab = jQuery(".stats-tabs.demos li.selected a").attr("rel");
		jQuery(".stats-tabs.demos li a").click(function(){
			jQuery(".stats-tabs.demos li.selected").removeClass("selected");
			jQuery(this).parent().addClass("selected");
			tab = jQuery(this).attr("rel");
			jQuery(jQuery.demotab).slideUp();
			jQuery(tab).slideDown();
			jQuery.demotab = tab;
			return false;
		});
	
		jQuery(".channel-product-tabs li a").click(function(){
			// Compile the request location
			post_page = ThemeAjax.ajaxurl;
			
			jQuery(".channel-product-tabs li.selected").removeClass("selected");
			jQuery(this).parent().addClass("selected");
			
			rel = jQuery(this).attr("rel");
			jQuery("#channel_product").animate({opacity: 0.5});
			jQuery("#channel_product").attr("class", "loading");
			jQuery.post(post_page,
				{action : 'fetch_medium_details', postid: rel}, 
				function(data) {
					jQuery("#channel_product").html(data).animate({opacity: 1.0});
					jQuery("a.fancybox").fancybox();
				}
			);
			
			return false;
		});
	
	
		jQuery.featureproduct = 0;
		jQuery(".featured-product-slider .next").live("click", function(){
			position = jQuery(this).parent().parent().children("ul").position();
			count = jQuery(this).parent().parent().children("ul").children("li").size();
			maxleft = -(count*298);
			newleft = (position.left-298);
			
			
			if(newleft <= maxleft)
				newleft = 0;
			
			jQuery(this).parent().parent().children("ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;
		});
		
		jQuery(".featured-product-slider .previous").click(function(){
			position = jQuery(this).parent().parent().children("ul").position();
			count = jQuery(this).parent().parent().children("ul").children("li").size();	
			maxleft = -(count*298);
			newleft = (position.left+298);
			
			if(newleft > 0)
				newleft = (maxleft+298);
				
			jQuery(this).parent().parent().children("ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;
		});
		
		jQuery.channelproduct = 0;
		jQuery(".channel-product-slider .next").live("click", function(){
			position = jQuery(".channel-product-slider ul").position();
			count = jQuery(".channel-product-slider ul li").size();
			maxleft = -(count*560);
			newleft = (position.left-560);
			
			
			if(newleft <= maxleft)
				newleft = 0;
			
			jQuery(".channel-product-slider ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;	
		});
		
		jQuery(".channel-product-slider .previous").click(function(){
			position = jQuery(".channel-product-slider ul").position();
			count = jQuery(".channel-product-slider ul li").size();
			maxleft = -(count*560);
			newleft = (position.left+560);
			
			if(newleft > 0)
				newleft = (maxleft+560);
				
			jQuery(".channel-product-slider ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;
		});
		
		jQuery(".slide-it").click(function(){
			position = jQuery("#brand-slider ul").position();
			count = jQuery("#brand-slider ul").children("li").size();
			maxleft = -(count*80)+560;
			newleft = (position.left-310);

			if(newleft <= maxleft)
				newleft = 0;
				
			jQuery("#brand-slider ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;
		});
		jQuery(".opportunity-slider .next").live("click", function(){

			position = jQuery(".opportunity-slider ul").position();
			count = jQuery(".opportunity-slider ul li").size();
			maxleft = -(count*620);
			newleft = (position.left-620);
			
			
			if(newleft <= maxleft)
				newleft = 0;
			
			jQuery(".opportunity-slider ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;	
		});
	
		jQuery(".opportunity-slider .previous").click(function(){
			position = jQuery(".opportunity-slider ul").position();
			count = jQuery(".opportunity-slider ul li").size();
			maxleft = -(count*620);
			newleft = (position.left+620);
			
			if(newleft > 0)
				newleft = (maxleft+620);
				
			jQuery(".opportunity-slider ul").animate({"left": newleft+"px"}, {duration: 300});
			
			return false;
		});
			
		jQuery("#s").focus(function(){
			if(jQuery("#s").attr("value") == "Search")
				{jQuery("#s").attr("value", "");}
		});
		
		jQuery("#s").blur(function(){
			if(jQuery("#s").attr("value") == "")
				{jQuery("#s").attr("value", "Search");}
		});
		
		/*********************/
		/* Ink Drop Comments */		
		if(window.location.hash){
			commentScroll = jQuery(window.location.hash).offset().top;
			Screen.animate({scrollTop: commentScroll});
		}
		
		jQuery("#commentform").submit(function(){return false;});
		jQuery("#comment_jump").click(function(){
			setTimeout(function(){jQuery("html").animate({scrollTop: jQuery("#comment_anchor").offset().top}, 1000);}, 500);
			return false;
		});
		jQuery("#comment_submit").live("click", function(){
			// Compile the request location
			post_page = ThemeAjax.ajaxurl;
			
			// Compile all the request details
			author = jQuery("#author").attr("value");
			email = jQuery("#email").attr("value");
			url = jQuery("#url").attr("value");
			comment = jQuery("#comment").attr("value");
			twitter = jQuery("#twitter").attr("value");
			email_subscribe = jQuery("#email_subscribe").attr("checked");
			post_id = jQuery("#comment_post_id").attr("value");
			comment_parent_id = jQuery("#comment_parent_id").attr("value");
	
			// Set which area the new comment will end up in
			if(comment_parent_id !== "0" && comment_parent_id !== "")
				{new_comments_id = "#new-reply-"+comment_parent_id;}
			else
				{new_comments_id = "#new_comments";}
			
			// Fade out the new comment div so that we can fade it in after posting our new comment
			jQuery("#commment-post-alert").fadeIn("slow");
			
			// Perform the "Magic" which is just a bit of Ajax
			jQuery.post(post_page,
				{action : 'ocmx_comment-post', author: author, email: email, url: url, twitter: twitter, email_subscribe: email_subscribe, comment: comment, comment_post_id: post_id, comment_parent: comment_parent_id}, 
				function(data) {
					if(jQuery.browser.msie)
						{location.reload();}
					else
						{jQuery(new_comments_id).html(jQuery(new_comments_id).html()+" "+data).fadeIn("slow");}
					jQuery("#commment-post-alert").fadeOut("fast");
					jQuery("#comment").attr("value", "");
			});
			return false;
		});
		
		jQuery("a[id^='reply-']").live("click", function(){
			// Create the Comment Id and apply it to the comment form
			comment_id = jQuery(this).attr("id").replace("reply-", "");
			
			// Set which href we're dealing with
			href_id = "#reply-"+comment_id;
			
			//Set where exactly the comment form will end up
			new_location_id = "#form-placement-"+comment_id;
			
			//Create the Id for the new placement of the comment Form and put it there
			if(jQuery(new_location_id).html().toString().indexOf("Post") == -1)
				{
					jQuery("#comment_form_container").remove().appendTo(new_location_id);
					jQuery(new_location_id).fadeIn("slow");
					jQuery("#comment_parent_id").attr("value", comment_id);
					// Change href to Cancel
					jQuery(href_id).html("Cancel Reply");
				}
			else
				{
					jQuery(new_location_id).fadeOut("fast");
					jQuery("#comment_form_container").remove().appendTo("#original_comment_location");
					jQuery("#comment_parent_id").attr("value", "0");
					// Change href back to Reply
					jQuery(href_id).html("Reply");
				}
			setTimeout(function(){jQuery("html").animate({scrollTop: jQuery("#comment_form_container").offset().top}, 1000);}, 500);
			return false;
		});		
	});


