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');
var rttheme_template_dir = jQuery("meta[name=rttheme_template_dir]").attr('content');

//home page slider 
var showEffect;

//description area effect
showEffect="true";

jQuery(document).ready(function(){
	var slider_area;
	var slider_buttons;

	// Which slider
	if (jQuery('#slider_area').length>0){
		
		// Home Page Slider
		slider_area="#slider_area";	
		slider_buttons=".slider_thumbs";	
	
		jQuery(slider_area).cycle({ 
			fx:     rttheme_effect_options, 
			timeout:  rttheme_slider_time_out, 
			easing: 'backout', 
                pager:  '.slider_thumbs', 
			cleartype:  1,
			pause:           true,     // true to enable "pause on hover"
			pauseOnPagerHover: true,   // true to pause when hovering over pager link				
			before:  onBefore, 
			after:   onAfter ,				
			pagerAnchorBuilder: function(idx) { 
				 return '.slider_thumbs li:eq(' + idx + ') a'; 
			}
		});
		
	} 

	if (jQuery('.news_bar').length>0){
		
		// news bar
		news_bar=".news_bar"; 

		jQuery(news_bar).cycle({ 
			fx:     'scrollDown', 
			timeout:  6000,
			cleartype:  1
		});
		
	}


	if (jQuery('.product_image_slider .image').length>1){
		
		// news bar
		product_image_slider=".p_box .thumbs";	

		jQuery('.product_image_slider').cycle({ 
			fx:     'scrollUp', 
			timeout:  rttheme_slider_time_out,
			pager:  product_image_slider, 
			cleartype:  1,
			pause:           true,     // true to enable "pause on hover"
			pauseOnPagerHover: true,   // true to pause when hovering over pager link				
			before:  onBefore, 
			after:   onAfter ,				
			pagerAnchorBuilder: function(idx) { 
				 return product_image_slider +' li:eq(' + idx + ') a'; 
			}			
		});
		
	}	
        
	function onBefore() {
		if (showEffect!="false"){
			jQuery('.desc').stop().animate({left:-700},0);
		}else{
				
		}
	}
        
	function onAfter() {
		if (showEffect!="false"){
			jQuery('.desc').stop().animate({left:0},600);
		}else{
				
		}			
	}
     
     
     
	if (jQuery('.sub_slider').length>0){
		
		// Sub Page Slider
		sub_slider_area=".sub_slider";	

		jQuery(sub_slider_area).cycle({ 
			fx:     'fade', 
			timeout:  6000,
			pager:'.sub_slider_pager',
			cleartype:  1
		});
		
	}
     
	
});
 
//pretty photo
jQuery(document).ready(function(){
        jQuery("a[rel^='prettyPhoto']").prettyPhoto();
});

//cufon fonts
var rttheme_disable_cufon= jQuery("meta[name=rttheme_disable_cufon]").attr('content');
if(rttheme_disable_cufon!='true') {
	   jQuery(document).ready(function(){		
            Cufon.replace('h1,h2,h3,h4,h5,h6, #navigation > li > a, .cufon', {
               hover: true,		  
               textShadow: '1px 1px #fff' 
            });
            
            Cufon.replace('.desc .title', {
               hover: true
            });
	   });
}	 
	 
 
//drop down menu
jQuery(document).ready(function() {
	jQuery("#navigation li").each(function()
	{
         
            jQuery(this).hover(function()
            {
                   
                       jQuery(this).find('ul:first').stop().css({
                             paddingTop:"8px",                              
                             height:"auto",
                             overflow:"hidden",
                             display:"none"
                             }).slideDown(200, function()
                       {
                       jQuery(this).css({
                             height:"auto",
                             overflow:"visible"
                       });
            });
                       
            },
            
            function()
            {	
                 jQuery(this).find('ul:first').stop().slideUp(200, function()
                 {	
                         jQuery(this).css({
                          display:"none",
                          overflow:"hidden"
                          });
                 });
            });	
	});
        
        jQuery("#navigation ul ").css({
            display: "none"}
         ); 
});
 
 
jQuery(document).ready(function() {
jQuery(".j_ttip[title]").tooltip({

   // tweak the position
	position: "top center",
         offset: [-20, 0],

   // use the "slide" effect
   effect: 'slide'

// add dynamic plugin with optional configuration for bottom edge
}).dynamic({ bottom: { direction: 'down', bounce: true } });


});


//search field function
jQuery(document).ready(function() {
	var search_text=jQuery(".search_bar .search_text").val();

	jQuery(".search_bar .search_text").focus(function() {
		jQuery(".search_bar .search_text").val('');
	});

	jQuery(".search_bar .search_text").focus(function() {
		jQuery(".search_bar .search_text").val('');
	});
         
 
       
         jQuery(".search_bar form .searchsubmit").css( {opacity:"0"} )
         jQuery(".search_bar")

          .mouseover(function(){
                 jQuery(".search_bar form .searchsubmit").stop().animate(
                         {opacity:"1"}, 
                         {duration:500})
                 })
          .mouseout(function(){
                 jQuery(".search_bar form .searchsubmit").stop().animate(
                         {opacity:"0"}, 
                         {duration:500})
                 })
 

});
jQuery(document).ready(function() {

var styling =".question{font-weight:bold; cursor:pointer; padding-bottom:5px;}" +
					  ".answer{display:block; font-size:11px; line-height:14px;}" +
					  ".opened{color:#2f6b80;}" +
					  ".closed{color:#015881;}";		
		//attach style to the page
		var style = document.createElement("style");
        style.type = "text/css";
        try {
            style.appendChild( document.createTextNode(styling) );
        } catch (e) {
            if ( style.styleSheet ) {
                style.styleSheet.cssText = styling;
            }
        }
        document.body.appendChild( style );
//style all questions as closed
		$(".question").addClass("closed"); 
		//make sure first question is styled as open
	    //$(".question:first").removeClass("closed").addClass("opened"); 
		$(".answer").hide(); //hide answers
		//$(".answer:first").show(); //show first answer
		//question click
		$(".question").click(function() {
			$(".answer").slideUp("fast");
			$(".question").removeClass("opened").addClass("closed");
	
			if ($(this).next(".answer").is(":hidden")) {
				$(this).next(".answer").slideDown("fast");
				$(this).removeClass("closed").addClass("opened");
			} 			   
		});
});


//RT Portfolio Effect
jQuery(document).ready(function() {
        
        jQuery(window).load(function() {
                  var portfolio_item=jQuery("a.imgeffect");
                  
                  portfolio_item.each(function(){
                  
                           var img_width = jQuery(this).find('img').width();  
                           var img_height = jQuery(this).find('img').innerHeight();
                           var imageClass = jQuery(this).attr("class");
                           jQuery(this).prepend('<span class="imagemask '+imageClass+'"></span>');
                           
                           var p = jQuery(this).find('img');
                           var position = p.position();
                           var PosTop= parseInt(p.css("margin-top"))+position.top;
                           var PosLeft= parseInt(p.css("margin-left"))+position.left;
			   if (!PosLeft) {PosLeft= position.left};
                           
                           jQuery(this).find('.imagemask').css({top: PosTop});
			   jQuery(this).find('.imagemask').css({left: PosLeft});
                           
                           jQuery('.imagemask', this).css({width:img_width,height:img_height,backgroundPosition:'center center'});
                           
                           if(jQuery.browser.msie){ jQuery('.imagemask', this).css({display:'none'});}
                           
                  });
                  
         });
        
        
         var image_e= jQuery("a.imgeffect");
		
		if(jQuery.browser.msie){//ignore the shadow effect if browser IE
			 
				image_e.mouseover(function(){
					 
				jQuery(this).find('.imagemask').stop().css({
						  display:"block"
						  }); 
					 
				}).mouseout(function(){
					jQuery(this).find('.imagemask').stop().css({
						 display:"none"
						} );
				});
			 
		}else{//real browsers :)
			 image_e.mouseover(function(){
				  
			 jQuery(this).find('.imagemask').stop().animate({
					   display:"block",
					   opacity:1
					   }, 500); 
				  
			 }).mouseout(function(){
				 jQuery(this).find('.imagemask').stop().animate({
					   display:"none",
					   opacity:0
					 }, 400 );
			 });                  
		}

});


//////MAP PLUGIN
(function(f){var b,c,j,m,l,i,g,e,h,a,k;b=document.namespaces;has_canvas=document.createElement("canvas");has_canvas=has_canvas&&has_canvas.getContext;if(!(has_canvas||b)){f.fn.maphilight=function(){return this};return}if(has_canvas){g=function(p,o,n){if(o<=1){p.style.opacity=o;window.setTimeout(g,10,p,o+0.1,10)}};e=function(n){return Math.max(0,Math.min(parseInt(n,16),255))};h=function(n,o){return"rgba("+e(n.substr(0,2))+","+e(n.substr(2,2))+","+e(n.substr(4,2))+","+o+")"};c=function(n){var o=f('<canvas style="width:'+n.width+"px;height:"+n.height+'px;"></canvas>').get(0);o.getContext("2d").clearRect(0,0,o.width,o.height);return o};j=function(q,n,t,p,o){var s,r=q.getContext("2d");r.beginPath();if(n=="rect"){r.rect(t[0],t[1],t[2]-t[0],t[3]-t[1])}else{if(n=="poly"){r.moveTo(t[0],t[1]);for(s=2;s<t.length;s+=2){r.lineTo(t[s],t[s+1])}}else{if(n=="circ"){r.arc(t[0],t[1],t[2],0,Math.PI*2,false)}}}r.closePath();if(p.fill){r.fillStyle=h(p.fillColor,p.fillOpacity);r.fill()}if(p.stroke){r.strokeStyle=h(p.strokeColor,p.strokeOpacity);r.lineWidth=p.strokeWidth;r.stroke()}if(p.fade){g(q,0)}};m=function(n,o){n.getContext("2d").clearRect(0,0,n.width,n.height)}}else{c=function(n){return f('<var style="zoom:1;overflow:hidden;display:block;width:'+n.width+"px;height:"+n.height+'px;"></var>').get(0)};j=function(o,r,s,v,n){var t,u,p,q;t='<v:fill color="#'+v.fillColor+'" opacity="'+(v.fill?v.fillOpacity:0)+'" />';u=(v.stroke?'strokeweight="'+v.strokeWidth+'" stroked="t" strokecolor="#'+v.strokeColor+'"':'stroked="f"');p='<v:stroke opacity="'+v.strokeOpacity+'"/>';if(r=="rect"){q=f('<v:rect name="'+n+'" filled="t" '+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+s[0]+"px;top:"+s[1]+"px;width:"+(s[2]-s[0])+"px;height:"+(s[3]-s[1])+'px;"></v:rect>')}else{if(r=="poly"){q=f('<v:shape name="'+n+'" filled="t" '+u+' coordorigin="0,0" coordsize="'+o.width+","+o.height+'" path="m '+s[0]+","+s[1]+" l "+s.join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+o.width+"px;height:"+o.height+'px;"></v:shape>')}else{if(r=="circ"){q=f('<v:oval name="'+n+'" filled="t" '+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(s[0]-s[2])+"px;top:"+(s[1]-s[2])+"px;width:"+(s[2]*2)+"px;height:"+(s[2]*2)+'px;"></v:oval>')}}}q.get(0).innerHTML=t+p;f(o).append(q)};m=function(n){f(n).find("[name=highlighted]").remove()}}l=function(o){var n,p=o.getAttribute("coords").split(",");for(n=0;n<p.length;n++){p[n]=parseFloat(p[n])}return[o.getAttribute("shape").toLowerCase().substr(0,4),p]};k=function(p,o){var n=f(p);return f.extend({},o,f.metadata?n.metadata():false,n.data("maphilight"))};a=function(n){if(!n.complete){return false}if(typeof n.naturalWidth!="undefined"&&n.naturalWidth==0){return false}return true};i={position:"absolute",left:0,top:0,padding:0,border:0};var d=false;f.fn.maphilight=function(p){p=f.extend({},f.fn.maphilight.defaults,p);if(f.browser.msie&&!d){document.namespaces.add("v","urn:schemas-microsoft-com:vml");var o=document.createStyleSheet();var n=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];f.each(n,function(){o.addRule("v\\:"+this,"behavior: url(#default#VML); antialias:true")});d=true}return this.each(function(){var v,s,y,r,u,w,x,t;v=f(this);if(!a(this)){return window.setTimeout(function(){v.maphilight(p)},200)}y=f.extend({},p,f.metadata?v.metadata():false,v.data("maphilight"));r=f('map[name="'+v.attr("usemap").substr(1)+'"]');if(!(v.is("img")&&v.attr("usemap")&&r.size()>0)){return}if(v.hasClass("maphilighted")){var q=v.parent();v.insertBefore(q);q.remove()}s=f('<div class="'+f(this).attr("class")+'"></div>').css({display:"block",background:"url("+this.src+")",position:"relative",padding:0,width:this.width,height:this.height});v.before(s).css("opacity",0).css(i).remove();if(f.browser.msie){v.css("filter","Alpha(opacity=0)")}s.append(v);u=c(this);f(u).css(i);u.height=this.height;u.width=this.width;x=function(B){var z,A;A=k(this,y);if(!A.neverOn&&!A.alwaysOn){z=l(this);j(u,z[0],z[1],A,"highlighted");if(A.groupBy&&f(this).attr(A.groupBy)){var C=this;r.find("area["+A.groupBy+"="+f(this).attr(A.groupBy)+"]").each(function(){if(this!=C){var E=k(this,y);if(!E.neverOn&&!E.alwaysOn){var D=l(this);j(u,D[0],D[1],E,"highlighted")}}})}}};if(y.alwaysOn){f(r).find("area[coords]").each(x)}else{f(r).find("area[coords]").each(function(){var z,A;A=k(this,y);if(A.alwaysOn){if(!w){w=c(v.get());f(w).css(i);w.width=v.width();w.height=v.height();v.before(w)}z=l(this);if(f.browser.msie){j(u,z[0],z[1],A,"")}else{j(w,z[0],z[1],A,"")}}});f(r).find("area[coords]").mouseover(x).mouseout(function(z){m(u)})}v.before(u);v.addClass("maphilighted")})};f.fn.maphilight.defaults={fill:true,fillColor:"000000",fillOpacity:0.2,stroke:true,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,fade:true,alwaysOn:false,neverOn:false,groupBy:false}})(jQuery);
 
 
//validate contact form
jQuery(document).ready(function(){

      // show a simple loading indicator
      var loader = jQuery('<img src="images/loading.gif" alt="..." />')
              .appendTo(".loading")
              .hide();
      jQuery().ajaxStart(function() {
              loader.show();
      }).ajaxStop(function() {
              loader.hide();
      }).ajaxError(function(a, b, e) {
              throw e;
      });
      
      jQuery.validator.messages.required = "";
      var v = jQuery("#validate_form").validate({
              submitHandler: function(form) {
                      jQuery(form).ajaxSubmit({
                              target: "#result"
                      });
              }
      });
      
      jQuery("#reset").click(function() {
              v.resetForm();
      });
	  
	  $.fn.maphilight.defaults = {
		fill: true,
		fillColor: '000000',
		fillOpacity: 0.2,
		stroke: false,
		strokeColor: 'ff0000',
		strokeOpacity: 1,
		strokeWidth: 1,
		fade: true,
		alwaysOn: false,
		neverOn: false,
		groupBy: false
	}
	$('.map').maphilight();
	
 });
 
 function loaddetails(details){
	$(".regiondetail").hide();
	var h = 400+$("#"+details).height();
				
	$("#container").height(h);
	$("#"+details).show();
	
}


