// JavaScript Document
//łśćłżź
var DebugQueryMode=false; //Show Alerts
var DebugConsoleMode=false; //Show Alerts only for specific url's ex. with ?jconsole
//var IE=false;

/* =============================== .jConsole [START] ================================ */
var Debug_url=window.location.toString();
var Debug_varexists=Debug_url.indexOf('?');
//var Debug_number=-1;
if(Debug_varexists>0){
	var Debug_var=Debug_url.slice(Debug_varexists,Debug_url.length);
	switch(Debug_var){
		case '?jconsole': DebugConsoleMode=true; break;
		default: break; //c_number=-1;
	}
	//if(Debug_number!=-1){ }
} //if
/* =============================== .jConsole [END] ================================== */
/* ================================================================================== */
/* =============================== jquery.ready [START] ============================= */
/* ================================================================================== */
/* =============================== .jAjax [START] =================================== */
/*
var Global_jAjaxPerm=true;
function jAjax2OLD(){
	try{
		if(Global_jAjaxPerm==false){ self.setTimeout("jAjax('"+'test'+"')", 300); }
		elements=$JQ('.jAjax');
		
		var glob=0;
		for(i=0;i<elements.length;i++){
			c_href='';
			single=$JQ(elements).eq(i).find('.jAjax_link');
			//alert(single.length);
			if(single.length==1){ c_href=$JQ(single).eq(0).attr('href'); }
			if(c_href!='' && c_href !='#'){
				$JQ(elements).eq(i).attr('class','.jAjaxDone');
				
				$JQ(elements).eq(i).bind("ajaxSend", function(){
					Global_jAjaxPerm=false;
					$JQ(this).unbind('ajaxSend');
					$JQ(this).hide();
					
				}).bind("ajaxComplete", function(){
					$JQ(this).unbind('ajaxError');
					$JQ(this).unbind('ajaxComplete');
					$JQ(this).show(800, function(){ Global_jAjaxPerm=true; });					
					
				}).bind("ajaxError", function(){
					$JQ(this).unbind('ajaxError');
					$JQ(this).unbind('ajaxComplete');
					$JQ(this).html('<div class="loading"><img src="/bc_graph/shared/empty.gif" alt="" width="18" height="18" /></div>');
					$JQ(this).show(800, function(){ Global_jAjaxPerm=true; });
				});
				Global_jAjaxPerm=false;
				$JQ(elements).eq(i).load(c_href);
				self.setTimeout("jAjax('"+'test'+"')", 300);
				return false;
			}//if
			
		}//for
	}catch(err){ if(DebugQueryMode==true){ alert(' jAjax: '+err); }}
}
*/

(function($JQ){
	var _sleeptimer;
	$JQ.sleep = function( time2sleep, callback )
	{
		$JQ.sleep._sleeptimer = time2sleep;
		$JQ.sleep._cback = callback;
		$JQ.sleep.timer = setInterval('$JQ.sleep.count()', 1000);
	}
	$JQ.extend ($JQ.sleep, {
		current_i : 1,
		_sleeptimer : 0,
		_cback : null,
		timer : null,
		count : function()
		{
			if ( $JQ.sleep.current_i === $JQ.sleep._sleeptimer )
			{
				clearInterval($JQ.sleep.timer);
				$JQ.sleep._cback.call(this);
			}
			$JQ.sleep.current_i++;
		}
	});
})(jQuery);




function jAjaxIndividual(This,url){
	try{
		  $JQ.ajax({
			 url: url,
			 global: false,
			 beforeSend: function(){
				$JQ(This).css('opacity',0);
				$JQ(This).html('<div class="jAjax_loading">Loading. Please wait.</div>');
				$JQ(This).animate({opacity:1},{easing:"swing", queue:false,duration:150, complete:function(){     }});
			 },
			 success: function(data) {
				$JQ(This).animate({opacity:0},{easing:"swing", queue:false,duration:900, complete:function(){
					$JQ(This).html(data);
					var c_height=parseInt($JQ(This).attr('offsetHeight'))-parseInt($JQ(This).css('paddingTop'))-parseInt($JQ(This).css('paddingBottom'));
					$JQ(This).css('height',0);
					$JQ(This).animate({opacity:1, height:c_height},{easing:"easeInOutSine", queue:false,duration:300, complete:function(){ $JQ(This).css('height','auto');  }});
				}}); //animate
				
			 },
			 error: function(){
				$JQ(This).animate({opacity:0},{easing:"swing", queue:false,duration:900, complete:function(){
					$JQ(This).html('<div class="jAjax_error">Unable to load window</div>');
					var c_height=parseInt($JQ(This).attr('offsetHeight'))-parseInt($JQ(This).css('paddingTop'))-parseInt($JQ(This).css('paddingBottom'));
					$JQ(This).animate({opacity:1, height:c_height},{easing:"easeInOutSine", queue:false,duration:300, complete:function(){ 
						$JQ.sleep(10, function(){
							$JQ(This).animate({opacity:0, height:0},{easing:"swing", queue:false,duration:900, complete:function(){  $JQ(This).hide();  }});
						}); //sleep
						
					}}); //animate
				}}); //animate
			 }
		  });
	}catch(err){ if(DebugQueryMode==true){ alert(' jAjaxIndividual: '+err); }}
}



function jAjax(){
	try{
		elements=$JQ('.jAjax');
		for(i=0;i<elements.length;i++){
			c_href='';
			single=$JQ(elements).eq(i).find('.jAjax_link');
			if(single.length==1){ c_href=$JQ(single).eq(0).attr('href'); }
			if(c_href!='' && c_href !='#'){
				$JQ(elements).eq(i).attr('class','.jAjaxDone');
				jAjaxIndividual($JQ(elements).eq(i),c_href);
			}//if
		}//for
	}catch(err){ if(DebugQueryMode==true){ alert(' jAjax: '+err); }}
}


function jAjaxSliderSet(){
	try{
		var elements = $JQ('a');
		for(i=0;i<=elements.length;i++){
			if($JQ(elements).eq(i).attr('rel')=='jslider'){
				$JQ(elements).eq(i).click(function () {
					var new_href=$JQ(this).attr('href');
					if(new_href=='' || new_href=='#'){ return false; }
					//var new_href='https://myhealthangel01.worldsecuresystems.com/mini/help/programs_faq/my_weight.html';
					//cmsSlideShow(new_href);
					jAjaxSlider(new_href);
					return false;
				});
				
				$JQ(elements).eq(i).bind("ajaxError", function(){
					//$JQ(this).unbind('ajaxError');
					//$JQ(this).unbind('ajaxComplete');
					
					$JQ('#layer_slider').html('<a class="layer_slider_close" href="#"><img src="/bc_graph/shared/empty.gif" alt="" /></a><div class="loading_error" style="display:none">Unable to load page</div>');
					$JQ(".layer_slider_close").click(function () { 
						$JQ('#layer_main').remove();
						return false;
					});
					$JQ('#layer_slider .loading_error').show(100);
					
					//$JQ('#layer_opacity').animate({opacity:0}, 4000,"swing",function() {  });  
					//$JQ('#layer_slider').animate({opacity:0.9}, 2000,"linear",function() {  $JQ('#layer_main').remove(); });  
					return true;
				}).bind("ajaxComplete", function(){
					//$JQ(this).unbind('ajaxError');
					//$JQ(this).unbind('ajaxComplete');
					$JQ('#layer_slider .layer_slider_close').css('opacity',0);	
					$JQ('#layer_slider .layer_slider_close').animate({opacity:1}, 800,"swing");
					return false;
				});
				
				
			}
		}	
		
		
			
	}catch(err){ if(DebugQueryMode==true){ alert(' jAjaxSliderSet: '+err); }}
}

function jAjaxSlider(c_href){
	try{
		//alert('tet');
		var elements=$JQ('#layer_main');
		if(elements.length>0){ return false; }
		$JQ('body').prepend('<div class="layer_main" id="layer_main"></div>');
		$JQ('#layer_main').append('<div class="layer_opacity" id="layer_opacity"></div>');
		$JQ('#layer_main').append('<div class="layer_slider" id="layer_slider" align="center"><a class="layer_slider_close" href="#"><img src="/bc_graph/shared/empty.gif" alt="" /></a></div>');
		
		$JQ('#layer_slider').append('<div class="layer_slider_ajax"><div class="jAjax"><a class="jAjax_link" href="'+c_href+'"></a></div></div>');
		
		$JQ('#layer_slider .layer_slider_close').css('opacity',0);
		$JQ('#layer_main').css('height', $JQ('body').attr('scrollHeight'));
		$JQ('#layer_opacity').css('height', $JQ('body').attr('scrollHeight'));
		
		
		var scrolls=getScrollXY();
		var c_top=scrolls[1]+150;
		$JQ('#layer_slider').animate({top:c_top}, 60, "linear");
		
		$JQ(".layer_opacity").click(function () { 
		  	$JQ('#layer_main').remove();
		  	return false;
		});
		
		$JQ(".layer_slider_close").click(function () { 
		  	$JQ('#layer_main').remove();
		  	return false;
		});
		
		$JQ('#layer_opacity').css('opacity',0);
		$JQ('#layer_main').show();
		jAjaxSliderPosition();
		$JQ('#layer_opacity').animate({opacity:0.6}, 1000,"swing",function() { jAjax();  });
		
		
		//$JQ('#layer_main').show(1000, );
		
		
		
	}catch(err){ if(DebugQueryMode==true){ alert(' jAjaxSlider: '+err); }}
}

function jAjaxSliderPosition(){
	try{
		var elements=$JQ('#layer_main');
		if(elements.length!=1){ return false; }
		
		c_bodywidth=parseInt($JQ('body').attr('offsetWidth'));
		if(c_bodywidth<1000){ c_bodywidth=1000; }
		
		$JQ('#layer_main').css('width',c_bodywidth);
		$JQ('#layer_opacity').css('width',c_bodywidth);
		
		if(parseInt($JQ('.layer_slider_ajax').attr('offsetHeight'))>=430){ 
			$JQ('.layer_slider_ajax').css('padding-right','18px');
		}
		
		var c_left=parseInt((c_bodywidth/2)- ($JQ('#layer_slider').attr('offsetWidth')/2 ));
		//var scrolls=getScrollXY();
		//var c_top=scrolls[1]+150;
		
		//$JQ('#layer_slider').css('left',c_left);
		//$JQ('#layer_slider').css('top',c_top);
		$JQ('#layer_slider').animate({left:c_left}, 60, "linear");
		//$JQ('#layer_slider').animate({top:c_top}, 60, "linear");
		self.setTimeout("jAjaxSliderPosition('"+'test'+"')", 400);
		
	}catch(err){ if(DebugQueryMode==true){ alert('jAjaxSliderPosition: '+err); }}
}
/* =============================== .jAjax [END] ===================================== */
/* =============================== .SliderMVA [START] =============================== */
function jSliderMVA_Set(event){
	try{
		var IDlink=event.data.IDlink;
		var IDslide=event.data.IDslide;
		
		if(jQuery.data(document.body,IDslide).PERM!=true){ return false; }
		else{ jQuery.data(document.body,IDslide,{PERM:false}); }
		
		
		$JQ('#'+IDlink+' li').attr('class','');
		$JQ('#'+IDlink+' li').eq(event.data.LINKindex).attr('class','active');
		var c_fullwidth=parseInt($JQ('#'+IDslide+' ul').css('width'));
		var c_width=parseInt($JQ('#'+IDslide+' li').eq(0).attr('offsetWidth'));
		var c_left=parseInt($JQ('#'+IDslide+' ul').css('left'));
		
		var c_newlt=event.data.LINKindex*c_width*(-1);
		var c_newheight=$JQ('#'+IDslide+' li').eq(event.data.LINKindex).attr('offsetHeight');
		//$JQ('#'+IDslide+' ul').animate({ left:c_newlt },{easing:"easeOutElastic",duration:1500, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		//$JQ('#'+IDslide).animate({ height:c_newheight },{easing:"swing",duration:750, queue:false, complete:function(){     }}); //setHeight
		
		$JQ('#'+IDslide+' ul').animate({ left:c_newlt },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		$JQ('#'+IDslide).animate({ height:c_newheight },{easing:"swing",duration:750, queue:false, complete:function(){     }}); //setHeight
		//easeInOutExpo
		//alert(c_active);
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_Set: ' + err); }}
}

function jSliderMVA_Direction(event){
	try{
		var IDlink=event.data.IDlink;
		var c_direction=event.data.Direction;
		
		var elements=$JQ('#'+IDlink+' li');
		var c_active=-1;
		
		for(var i=0;i<elements.length;i++){
			if($JQ(elements).eq(i).attr('class')=='active'){  c_active=i; break; }
		}
		if(c_active==-1){ alert('MVA Error: #50'); return false;  }
		
		switch(c_direction) {
			case 'next': if(c_active<elements.length-1){ c_active+=1; }else{ c_active=0; }  break;
			case 'prev': if(c_active>=1){ c_active-=1; }else{ c_active=elements.length-1; }  break;
			default: return false;
		}
		//alert('ter:'+c_active+' - direction:'+c_direction); 
		if(c_active>=0 && c_active<elements.length){ $JQ(elements).eq(c_active).click(); }
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_Direction: ' + err); }}
}
			
			
function jSliderMVA(IDprev, IDnext, IDlink, IDslide, Num){
	try{ 
		if(!IDprev || IDprev==''){ return false; }
		if(!IDnext || IDnext==''){ return false; }
		if(!IDlink || IDlink==''){ return false; }
		if(!IDslide || IDslide==''){ return false; }
		if(!Num || Num==''){ Num=-1; }else{ Num=parseInt(Num); }
		
		//alert('test');
		//
		var c_total=$JQ('#'+IDslide+' li').length; //setWidth
		var c_width=parseInt($JQ('#'+IDslide).find('li').eq(0).attr('offsetWidth'));
		var c_height=parseInt($JQ('#'+IDslide).find('li').eq(0).attr('offsetHeight'));
		if(c_total<=0 || c_width<=0){ return false; }

		$JQ('#'+IDslide).animate({ height:c_height },{easing:"swing",duration:750, queue:false, complete:function(){     }}); //setHeight
		$JQ('#'+IDslide+' ul').css('width',parseInt(c_total*c_width));
		$JQ('#'+IDslide+' ul').css('left',0);
		
		
		
		var elements=$JQ('#'+IDlink+' li');
		$JQ(elements).attr('class','');
		if((Num>0 && Num<elements.length) && (c_total==elements.length)){ 
			$JQ(elements).eq(Num).attr('class','active');
			$JQ('#'+IDslide+' ul').css('left',parseInt((-1)*Num*c_width));
			
		}else{ $JQ(elements).eq(0).attr('class','active'); }
		
		jQuery.data(document.body,IDslide,{PERM:true});
		for(var i=0; i<elements.length; i++){
			$JQ(elements).eq(i).bind("click", {IDprev:IDprev, IDnext:IDnext, IDlink:IDlink, IDslide:IDslide, LINKindex:i}, jSliderMVA_Set);
		}
		
		$JQ('#'+IDprev).bind("click", {IDprev:IDprev, IDnext:IDnext, IDlink:IDlink, IDslide:IDslide, Direction:'prev'}, jSliderMVA_Direction);
		$JQ('#'+IDnext).bind("click", {IDprev:IDprev, IDnext:IDnext, IDlink:IDlink, IDslide:IDslide, Direction:'next'}, jSliderMVA_Direction);
		
		jItemHoverAnimation(IDprev);
		jItemHoverAnimation(IDnext);
		//alert($JQ('#'+IDslide+' ul').css('width'));
		//for(var i=0;i<elements.length;i++){
			
		//}
		
		
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA: ' + err); }}
}

var GlobalSliderMVA_TimerPerm=false;
function jSliderMVA_TimerSet(IDprev, IDnext, IDlink, Duration){
	try{
		if(!IDprev || IDprev==''){ return false; }
		if(!IDnext || IDnext==''){ return false; }
		if(!IDlink || IDlink==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
	
		$JQ('#'+IDprev).bind("mouseover", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOver);
		$JQ('#'+IDprev).bind("mouseout", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOut);
		
		$JQ('#'+IDnext).bind("mouseover", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOver);
		$JQ('#'+IDnext).bind("mouseout", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOut);
		
		$JQ('#'+IDlink).find('a').bind("mouseover", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOver);
		$JQ('#'+IDlink).find('a').bind("mouseout", {IDprev:IDprev, IDnext:IDnext, Duration:Duration}, jSliderMVA_TimerOut);
		
		GlobalSliderMVA_TimerPerm=true;
		jSliderMVA_Timer(IDprev, IDnext, IDlink, Duration, 'firstrun');
		return true;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_TimerSet: ' + err); }}
}

function jSliderMVA_TimerOver(event){
	try{
		GlobalSliderMVA_TimerPerm=false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_TimerOver: ' + err); }}
}

function jSliderMVA_TimerOut(event){
	try{
		GlobalSliderMVA_TimerPerm=true;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_TimerOut: ' + err); }}
}

function jSliderMVA_Timer(IDprev, IDnext, IDlink, Duration, Status){
	try{
		if(!IDprev || IDprev==''){ return false; }
		if(!IDnext || IDnext==''){ return false; }
		if(!IDlink || IDlink==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
		if(!Status || Status==''){ Status=''; }
		
		if((GlobalSliderMVA_TimerPerm==true) && (Status!='firstrun')){
			//$JQ('#'+IDnext).click();
			var elements=$JQ('#'+IDlink+" li");
			for(var i=0;i<elements.length;i++){
				if($JQ(elements).eq(i).attr('class')=='active'){ break; }
			}
			if(i>=elements.length-1){ Status='prev'; }
			if(i==0){ Status='next'; }
			if(Status=='prev'){ $JQ('#'+IDprev).trigger('click'); }
			if(Status=='next'){ $JQ('#'+IDnext).trigger('click'); }
			
			self.setTimeout("jSliderMVA_Timer('"+IDprev+"','"+IDnext+"','"+IDlink+"',"+Duration+",'"+Status+"')",  Duration);
			return;
		}else{ Status='next'; self.setTimeout("jSliderMVA_Timer('"+IDprev+"','"+IDnext+"','"+IDlink+"',"+Duration+",'"+Status+"')",  Duration); }
		//self.setTimeout("jSliderMVA_Timer('"+IDprev+"','"+IDnext+"',"+Duration+")", 3000);
		
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVA_Timer: ' + err); }}
}

/* =============================== .SliderMVA [END] ================================= */
/* =============================== .single [START] ================================== */
/*
function jTopLogin(module_islogged){
	try{
		 if(module_islogged==1){ $JQ('#topbox_login').html('<a id="topbox_loginarea" href="/members/information.html">Members Area</a> (<a id="topbox_loginout" href="/LogOutProcess.aspx">Log out</a>)'); }
	
		return false;
		if(module_isloggedin==1){
			$JQ('#topbox_login').text('Customer Area');
			$JQ('#topbox_login').attr('href','/customer/information.html');
			$JQ('#topbox_login').after('<span style="padding-left:5px;"></span>(<a class=" " style="color:#ebb2b2" href="/LogOutProcess.aspx">Log out</a>)');
		}
	}catch(err){ if(DebugMode==true){ alert('setTopLogin: ' + err); }}
}
*/
function jTopAnimation(ID, c_left1, c_left2, c_left3){
	try{ 
		if(!ID || ID==''){
			var c_top=parseInt($JQ('#top_logo').css('top'));
			
			//$JQ('#top_logo').css('top',-82);
			$JQ('#top_logo').css('visibility','visible');
			$JQ('#top_logo').animate({top:c_top},{easing:"easeOutBounce",duration:2200} );
			
			/*var c_left1=parseInt($JQ('#top_text1').css('left'));
			var c_left2=parseInt($JQ('#top_text2').css('left'));
			var c_left3=parseInt($JQ('#top_text3').css('left'));
			
			$JQ('#top_text1').css('left',c_left1+1500);
			$JQ('#top_text2').css('left',c_left2+1500);
			$JQ('#top_text3').css('left',c_left3+1500);
			
			$JQ('#top_text1').css('visibility','visible');
			$JQ('#top_text2').css('visibility','visible');
			$JQ('#top_text3').css('visibility','visible');*/
		}
		/*
		switch(ID){
			case 'top_text1': ID='top_text2'; c_left=c_left2; break;
			case 'top_text2': ID='top_text3'; c_left=c_left3; break;
			case 'top_text3': return true; break;
			default: ID='top_text1'; c_left=c_left1;
		}
		$JQ('#'+ID).css('left',c_left+2000);
		$JQ('#'+ID).animate({left:c_left},{easing:"easeInOutQuad",duration:400, complete:function(){ jTopAnimation($JQ(this).attr('id'), c_left1, c_left2, c_left3);  }});
		return true;
		*/
	}catch(err){ if(DebugMode==true){ alert('jTopAnimation: ' + err); }}
}

function jMenuAnimation(ID){
	try{  
		if(!ID || ID==''){ return false; }
		
		$JQ('#'+ID).find('ul').find('li:last').css('background','none');
		var elements=$JQ('#'+ID).find('li ul');
		
		for(var i=0;i<elements.length;i++){
			$JQ(elements).eq(i).css('opacity',0);
			/*if(i!=0){ $JQ(elements).eq(i).before('<div class="menul_arrow"><div>'); }*/
			
			var c_width=parseInt($JQ(elements).eq(i).parent().attr('offsetWidth'));
			var c_subwidth=parseInt($JQ(elements).eq(i).css('width'));
			var c_left=parseInt((c_subwidth-c_width)/2)*(-1);
			if(c_subwidth!=0){ $JQ(elements).eq(i).css('left',c_left); } //OPERA Fix
			
			$JQ(elements).eq(i).parent().mouseover(function(){
				var element=$JQ(this).find('ul').eq(0);
				/*$JQ(this).find('ul').eq(0).css('display','block');*/ /*IE6.0 Fix*/
				$JQ(element).animate({opacity:1},{easing:"swing", queue:false,duration:800, complete:function(){ /**/  }});
				
			}).mouseout(function(){
				var element=$JQ(this).find('ul').eq(0);
				$JQ(element).stop(false,false);
				$JQ(element).animate({opacity:0},{easing:"swing", queue:false,duration:300, complete:function(){ /**/  }});
				
			});
			
		}//for
		//$JQ('#'+ID).css('left',c_left+2000);
		//$JQ('#'+ID).animate({left:c_left},{easing:"easeInOutQuad",duration:400, complete:function(){ jMenuAnimation($JQ(this).attr('id'), c_left1, c_left2, c_left3);  }});
		return true;
	}catch(err){ if(DebugMode==true){ alert('jMenuAnimation: ' + err); }}
}

function jSLIDER_Activate(ID, IDnav){
	try{  
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		var elements=$JQ('#'+ID+' li');
		var c_liwidth=parseInt($JQ(elements).eq(0).css('width'))*parseInt(elements.length);
		var c_ulwidth=parseInt($JQ('#'+ID).css('width'));
		if(c_ulwidth<c_liwidth){ $JQ('#'+ID).css('width',c_liwidth) }
		if(elements.length>0){
			$JQ('#'+IDnav).slider({
				value:1,
				min: 1,
				max: elements.length,
				step: 1,
				//slide: function(event, ui) { $JQ("#amount").html('$' + ui.value); },
				change: function(event, ui) { jSLIDER_Change(ID,$JQ(this).slider("value")); }
			});
		}
		return;
	}catch(err){ if(DebugMode==true){ alert('jSLIDER_Activate: ' + err); }}
}


var GlobalSlider_TimerPerm=false;
function jSlider_TimerSet(ID, IDnav, Duration){
	try{
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
	
		$JQ('#'+IDnav).bind("mouseover", {ID:ID, IDnav:IDnav, Duration:Duration}, jSlider_TimerOver);
		$JQ('#'+IDnav).bind("mouseout", {ID:ID, IDnav:IDnav, Duration:Duration}, jSlider_TimerOut);
		
		GlobalSlider_TimerPerm=true;
		jSlider_Timer(ID, IDnav, Duration, 'firstrun');
		return true;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerSet: ' + err); }}
}

function jSlider_TimerOver(event){
	try{
		GlobalSlider_TimerPerm=false;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerOver: ' + err); }}
}

function jSlider_TimerOut(event){
	try{
		GlobalSlider_TimerPerm=true;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerOut: ' + err); }}
}


function jSlider_Timer(ID, IDnav, Duration, Status){
	try{
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
		if(!Status || Status==''){ Status='right' }
		
		if(Status=='firstrun'){ Status='right'; self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration); return false; }
		
		if(GlobalSlider_TimerPerm==true){
			
			/*var c_value=parseInt($JQ('#'+IDnav).slider("value"))+1;
			var c_max=$JQ('#'+IDnav).slider('option', 'max');
			if(c_value>c_max){ c_value=$JQ('#'+IDnav).slider('option', 'min'); }
			$JQ('#'+IDnav).slider("value",c_value);
			self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+")",  Duration);*/
			//var c_value=parseInt($JQ('#'+IDnav).slider("value"))+1;
			
			//return false;
			
			//if(DebugConsoleMode==true){alert(c_value); }
			var c_value=-1;
			var c_actual=parseInt($JQ('#'+IDnav).slider("value"));
			var c_max=$JQ('#'+IDnav).slider('option', 'max');
			var c_min=$JQ('#'+IDnav).slider('option', 'min');
			
			if(Status=='right'){ 
				if(c_actual>=c_max){ Status='left'; jSlider_Timer(ID, IDnav, Duration, Status); return false; }
				else{ c_value=c_actual+1; }
			}
			if(Status=='left'){
				if(c_actual<=c_min){ Status='right'; jSlider_Timer(ID, IDnav, Duration, Status); return false;  }
				else{ c_value=c_actual-1; }
			}
			//if(DebugConsoleMode==true){ alert('Status:'+Status+' Value:'+c_value); }
			
			
			if((c_value>=c_min) && (c_value<=c_max)){ 	}
			else{ c_value=0;  /*error*/ }
			
			$JQ('#'+IDnav).slider("value",c_value);
			self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration);
			
			//if(c_value>c_max){ c_value=$JQ('#'+IDnav).slider('option', 'min'); }
			
			
			return;
		}else{ self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration); }
		//self.setTimeout("jSliderMVA_Timer('"+IDprev+"','"+IDnext+"',"+Duration+")", 3000);
		
	}catch(err){ if(jDebugMode==true){ alert('jSlider_Timer: ' + err); }}
}



function jSLIDER_Change(ID,Num){
	try{  
		if(!ID || ID==''){ return false; }
		if(!Num || Num=='' || Num<1){ return false; }
		
		GlobalSlider_TimerPerm=false;
		var elements=$JQ('#'+ID+' li');
		var c_liwidth=parseInt($JQ(elements).eq(0).css('width'));
		var c_position=c_liwidth*(Num-1)*(-1);
		//$JQ('#'+ID).animate({ left:c_position },{easing:"easeOutElastic",duration:1000, queue:false, complete:function(){ /**/ }});
		$JQ('#'+ID).animate({ left:c_position },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){
			GlobalSlider_TimerPerm=true;																			  
		}});//animate
		//easeInOutExpo
	}catch(err){ if(DebugMode==true){ alert('jSLIDER_Change: ' + err); }}
}


function jSliderAnimate(ID){
	try{  
		if(!ID || ID==''){ return false; }
		var c_height=0;
		if(ID=='slider_home'){ c_height=363; }
		if(ID=='slider_subpage'){ c_height=291; }
		if(c_height==0){ return false; }
		
		$JQ('#'+ID).animate({ height:c_height },{easing:"easeOutBounce",duration:2200, queue:false, complete:function(){ /**/ }});
		
		
	}catch(err){ if(DebugMode==true){ alert('jSliderAnimate: ' + err); }}
}

function jSliderAnimate2(ID){
	try{  
		if(!ID || ID==''){ return false; }
		if(ID!='slider_subpage'){ return false; }
		
		$JQ('#'+ID).animate({ opacity:1 },{easing:"swing",duration:2200, queue:false, complete:function(){  }});
		
	}catch(err){ if(DebugMode==true){ alert('jSliderAnimate2: ' + err); }}
}

var jTabs_perm=true;
function jTabs(ID){
	try{  
		if(!ID || ID==''){ return false; }
		
		//$JQ('#'+ID).find('ul').find('li:last').css('background','none');
		
		var elements=$JQ('#'+ID).find('a');
		for(var i=0;i<elements.length;i++){
			c_href=$JQ(elements).eq(i).attr('href');
			if(c_href!='' && c_href!='#'){
				
				$JQ(elements).eq(i).click(function(){
					$JQ('#'+ID).find('li').attr('class','');
					$JQ(this).parent().attr('class','active');
					$JQ('#tabs_cont').load($JQ(this).attr('href')); 
					return false;  
				});
				/*
				$JQ(elements).eq(i).hover(function(){
					if(jTabs_perm==false){ return false; }
					$JQ('#'+ID).find('li').attr('class','');
					$JQ(this).parent().attr('class','active');
					$JQ('#tabs_cont').load($JQ(this).attr('href')); 
					return false;  
				},function(){});
				*/
			}else{ $JQ(elements).eq(i).click(function(){ return false; }); }
		}
		
		
		$JQ('#tabs_cont').bind("ajaxSend", function(){
			jTabs_perm=false;
			var elements=$JQ(this).find('div');
			$JQ(elements).animate({opacity:0},{easing:"swing",queue:false,duration:400,complete:function(){ $JQ(elements).remove(); } } );
		}).bind("ajaxComplete", function(){
			$JQ(this).find('div').css('opacity',0);
			$JQ(this).find('div').animate({opacity:1},{easing:"swing",queue:false,duration:1000,complete:function(){ jTabs_perm=true;  } } );
		}).bind("ajaxError", function(){
			var c_error='<div class="tabs_ct"><br /><br />';
    		c_error+= '<h3 class="color_red">Page Not Found</h3>';
    		c_error+= '<p align="left"><br />We could not find the Web Page you requested. This is either because:</p>';
			c_error+= '<ul class="mdeul mdeul_bg0" style="padding:8px 0px 0px 16px;">';
			c_error+= '<li>There\'s an error in the address or link.</li>';
			c_error+= '<li>Or you have entered the address or link incorrectly.</li>';
			c_error+= '</ul>';
            c_error+= '</div>';
			$JQ(this).html(c_error);
			$JQ(this).stop(false,true);
			$JQ(this).find('div').css('opacity',0);
			$JQ(this).find('div').animate({opacity:1},{easing:"swing",queue:false,duration:1000,complete:function(){ jTabs_perm=true;  } } );
		});
		
		$JQ(elements).eq(0).click();
		return true;
	}catch(err){ if(DebugMode==true){ alert('jTabs: ' + err); }}
}

function jItemHoverAnimation(Name, Duration){
	try{ 
		if(!Name || Name=='' || Name.length<2){ return false; }
		if(!Duration || Duration==''){ Duration=300; }
		
		switch(Name.charAt(0)){
			case '.': break;
			case '#': break;
			default: Name='#'+Name;
		}
		
		$JQ(Name+' img').css('opacity',0);
		$JQ(Name+' img').css('visibility','visible');
		
		$JQ(Name).hover(function(){
			$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:Duration, queue:false, complete:function(){    }});
		},function(){
			$JQ(this).find('img').eq(0).animate({ opacity:0 },{easing:"swing",duration:Duration, queue:false, complete:function(){    }});
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jItemHoverAnimation: ' + err); }}
}
/* =============================== .single [END] ==================================== */

$JQ(document).ready( function(){
							  
	jItemHoverAnimation('.jitemhover','350');
	//jTopAnimation();
	//jSliderAnimate2('slider_subpage'); /*Update - Disabled*/
	//jSliderAnimate('slider_home'); /*Update - Disabled*/
	
	
	/*$JQ('#template_mder').css('width',0);
	$JQ('#template_mder').css('visibility','visible');
	$JQ('#template_mder').animate({width:251},{easing:"easeOutBounce",duration:2000} );
	
	$JQ('.subimg').css('opacity',0);
	$JQ('.subimg').css('visibility','visible');
	$JQ('.subimg').animate({opacity:1},{easing:"easeOutBounce",duration:2000} );*/
});
/* ================================================================================== */
/* =============================== jquery.ready [END] =============================== */
/* ================================================================================== */

