//home page slider
jQuery(document).ready(function(){
	var rttheme_effect_options = jQuery("meta[name=rttheme_effect_options]").attr('content');
	var rttheme_slider_time_out = jQuery("meta[name=rttheme_slider_time_out]").attr('content');
	var rttheme_slider_numbers = jQuery("meta[name=rttheme_slider_numbers]").attr('content');
	if(rttheme_slider_numbers=='true') 	{
		var numbers="#numbers";
	}	
	$('#slider_area').cycle({ 
		fx:    rttheme_effect_options,
		easing: 'backout', 
		cleartype:  1,		
		timeout: rttheme_slider_time_out ,
		pager:  numbers, 		
			pagerAnchorBuilder: function(idx) { 
				return '<li><a href="#" title="">' + (idx+1) + '</a></li>'; 
			} 
	});
});


//cufon fonts
	var rttheme_disable_cufon= jQuery("meta[name=rttheme_disable_cufon]").attr('content');
	if(rttheme_disable_cufon!='true') {
		$(document).ready(function(){
			Cufon.replace('h1,h2,h3,h4,h5,h6', {hover: true});
		});
	}


//navigation
	$(document).ready(function(){
			ddsmoothmenu.init({
				mainmenuid: "dropdown_menu", //menu DIV id
				orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
				classname: 'dropdown', //class added to menu's outer DIV
				//customtheme: ["#1c5a80", "#18374a"],
				contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
			})
 	});

//image effects 
	$(document).ready(function(){
			var image_e= $(".image.portfolio, .image.product_image");
			image_e.mouseover(function(){$(this).stop().animate({ opacity:0.6
					}, 400);
			}).mouseout(function(){
				image_e.stop().animate({ 
					opacity:1
					}, 400 );
			});
	});

//pretty photo
	$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto();
	});

// mimick str_replace() from the PHP world
function str_replace (search, replace, subject, count) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }
    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}


//product tabs
	$(document).ready(function(){
			var tabs= $("#tabs ul li");
			var content = $("#tabs #content");
			var kids = content.children();
			kids.attr("style","display:none;");
			$("#tabs #content div:first").attr("style","display:block;");
			tabs.click(
				function(){
//					var show=$(this).attr("title");
					var show=$("#tabs ul li").index(this);
					
					//change clicked tab class
					$("#tabs ul li").removeClass("active");
					$(this).addClass("active");
					//view clicked tab content
					kids.attr("style","display:none;");
					content.slideUp(400);
					$(function(){
						content.slideUp(400);
//						$("#"+show+"").attr("style","display:block;");
						$("#tabs #content div:eq("+show+")").attr("style","display:block;");
						content.slideDown(400);
					});
				}
			);
	});

//validate contact form
	  $(document).ready(function(){
		  jQuery.validator.messages.required = "";
			$("#validate_form").validate({});
	  });


