// JavaScript Document
//łśćłżź
var DebugQueryMode=true; //Show Alerts
//var IE=false;

/* ================================================================================== */
/* =============================== jquery.ready [START] ============================= */
/* ================================================================================== */
/* =============================== .jAjax [START] =================================== */
// Important, required function getScrollXY;
var Global_jAjaxPerm=true;
function jAjax(){
	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="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 jAjaxSliderSet(){
	try{
		var elements = $JQ('a');
		for(i=0;i<=elements.length;i++){
			if($JQ(elements).eq(i).attr('rev')=='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="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{
		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="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] ===================================== */
/* =============================== .nForm [START] =================================== */
function jnFormRadioClick(This){
	try{
		ID=$JQ(This).attr('id');
		var unique_name='';
		for(i=0;i<glob_nFormRadio.length;i++){
			if(glob_nFormRadio[i].idgraph==ID){
				//$JQ('#'+glob_nFormRadio[i].idgraph).attr('class','nform_check2');
				//$JQ('#'+glob_nFormRadio[i].idradio).attr('checked','checked');
				unique_name=glob_nFormRadio[i].name;
				break;				
			}
		}
		if(unique_name==''){ return false; }
		for(i=0;i<glob_nFormRadio.length;i++){
			if(glob_nFormRadio[i].name==unique_name){
				$JQ('#'+glob_nFormRadio[i].idgraph).attr('class','nform_check1');
				if(glob_nFormRadio[i].idgraph==ID){
					$JQ('#'+glob_nFormRadio[i].idgraph).attr('class','nform_check2');
					$JQ('#'+glob_nFormRadio[i].idradio).attr('checked','checked');
					$JQ('#'+glob_nFormRadio[i].idradio).change(); /*Added*/
				}
			}
		}//for
	}catch(err){ if(DebugQueryMode==true){ alert('jnFormRadioClick: '+err); }}
}

var glob_nFormRadio=new Array();

function jnFormRadioSet(IDarray){
	try{
		if(!IDarray || IDarray.length==0){ return false; }
		var unique_name='';
		for(i=0;i<IDarray.length;i++){
			c_id=IDarray[i];
			if(c_id.slice(0,12)=='nform_radio_'){
				c_idradio=c_id.slice(12,c_id.length);
				//alert(glob_nFormRadio.length)
				if(unique_name==''){ 
					unique_name=c_id;
					if(glob_nFormRadio.length){
						for(k=0;k<glob_nFormRadio.length;k++){
							if(glob_nFormRadio[k].name==unique_name){ return false; }
						}
					}
				}
				var air={}
				air.name=unique_name;
				air.idgraph=c_id;
				air.idradio=c_idradio;
				c_count=glob_nFormRadio.length
				
				if($JQ('#'+air.idradio).attr('checked')==true){
					$JQ('#'+air.idgraph).attr('class','nform_check2'); //set at start
				}
				
				if(!c_count){ c_count=0; }
				glob_nFormRadio[c_count]=air;
				
				$JQ('#'+c_id).click(function () { 
				  	jnFormRadioClick(this);
				});
						
			}
		}//for
	}catch(err){ if(DebugQueryMode==true){ alert('jnFormRadioSet: '+err); }}
}
/* =============================== .nForm [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); }}
}

/* =============================== .SliderMVA [END] ================================= */
/* =============================== .SliderMVB [START] =============================== */
function jSliderMVB_DirectionImgAuto(event,Active){
	try{
		var c_reset=false;
		if(!Active || Active==''){ c_reset=true; Active=0; }
		var IDimg=event.data.IDimg;
		var IDslide=event.data.IDslide;
		
		var c_width=parseInt($JQ('#'+IDimg+' li').eq(0).attr('offsetWidth'));
		var c_left=parseInt($JQ('#'+IDimg).find('ul').eq(0).css('left'));
		
		var c_newlt=c_left;
		var elements=$JQ('#'+IDimg+' li');
		var c_active=-1;
		
		for(var i=0;i<elements.length;i++){
			if(c_width*i*(-1)==c_left){ c_active=i; break; }
		}
		if((c_active==-1) || (elements.length<=5)){ /*alert('MVA Error: #50');*/ return false;  }
		
		//if(Active>c_active){ c_direction='next'; }
		//else{ c_direction='prev'; }
		
		var c_restmod=Active%5;
		var c_restdiv=parseInt(Active/5);
		
		if(c_reset==false){
			c_newlt=(-1)*c_restdiv*5*c_width;
			if(c_newlt<(-1)*(elements.length-5)*c_width){//right end
				c_newlt=(-1)*(elements.length-5)*c_width;
			}
		}else{ c_newlt=0; }
		
		//$JQ('#'+IDimg+' ul').animate({ left:c_newlt },{easing:"easeOutElastic",duration:1500, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		$JQ('#'+IDimg+' ul').animate({ left:c_newlt },{easing:"easeInOutExpo",duration:1150, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		//easeInOutExpo
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_DirectionImgAuto: ' + err); }}
}

function jSliderMVB_Set(event){
	try{ 
		var IDimg=event.data.IDimg;
		var IDslide=event.data.IDslide;
		
		if(jQuery.data(document.body,IDslide).PERM!=true){ return false; }
		else{ jQuery.data(document.body,IDslide,{PERM:false}); }
		
		$JQ('#'+IDimg+' li').attr('class','');
		$JQ('#'+IDimg+' li').eq(event.data.LINKindex).attr('class','active');
		jSliderMVB_DirectionImgAuto(event,event.data.LINKindex);
		
		//$JQ('#'+IDimg+' li').find('a').eq(event.data.LINKindex).mouseenter();//set border
		//$JQ('#'+IDimg+' li').find('a').mouseleave();//clear border
		
		//$JQ('#'+IDimg).find('li a').eq(event.data.LINKindex).mouseenter();//set border
		//$JQ('#'+IDimg).find('li a').mouseleave();//clear border
		
		$JQ('#'+IDimg).find('li').find('a').eq(event.data.LINKindex).mouseenter();//set border
		$JQ('#'+IDimg).find('li').find('a').mouseleave();//clear border
		
		
		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).find('ul').eq(0).animate({ left:c_newlt },{easing:"easeOutElastic",duration:1500, queue:false, complete:function(){  jQuery.data(document.body,IDslide,{PERM:true});  }}); //Safari Path
		$JQ('#'+IDslide).find('ul').eq(0).animate({ left:c_newlt },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){  jQuery.data(document.body,IDslide,{PERM:true});  }}); //Safari Path
		$JQ('#'+IDslide).animate({ height:c_newheight },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){     }}); //setHeight
		//alert(c_active);
		//easeInOutExpo,easeInOutBack,easeInOutCirc,easeInOutQuint
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_Set: ' + err); }}
}


function jSliderMVB_DirectionImg(event){
	try{
		var IDimg=event.data.IDimg;
		var IDslide=event.data.IDslide;
		var c_direction=event.data.Direction;
		
		//var c_fullwidth=parseInt($JQ('#'+IDimg+' ul').css('width'));
		var c_width=parseInt($JQ('#'+IDimg+' li').eq(0).attr('offsetWidth'));
		var c_left=parseInt($JQ('#'+IDimg).find('ul').eq(0).css('left'));
		var c_newlt=c_left;
		var elements=$JQ('#'+IDimg+' li');
		var c_active=-1;
		
		for(var i=0;i<elements.length;i++){
			if(c_width*i*(-1)==c_left){ c_active=i; break; }
		}
		if((c_active==-1) || (elements.length<=5)){ /*alert('MVA Error: #50');*/ return false;  }
		
		var c_distnext=elements.length-5-c_active;
		if(c_distnext>5){ c_distnext=5; }
		
		var c_distprev;
		if(c_active<=5){ c_distprev=c_active; }else{ c_distprev=5; }
		
		//alert(c_distnext);
		switch(c_direction) {
			case 'next': if(c_active<elements.length-5){ c_newlt-=c_distnext*c_width; }else{ c_newlt=0; }  break;
			case 'prev': if(c_active>=1){ c_newlt+=c_distprev*c_width; }else{ c_newlt=(-1)*(elements.length-5)*c_width; }  break;
			default: return false;
		}
		
		//$JQ('#'+IDimg+' ul').animate({ left:c_newlt },{easing:"easeOutElastic",duration:1500, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		$JQ('#'+IDimg+' ul').animate({ left:c_newlt },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){ jQuery.data(document.body,IDslide,{PERM:true});  }}); 
		//easeInOutExpo
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_Direction: ' + err); }}
}

function jSliderMVB_DirectionSlider(event){
	try{
		var IDimg=event.data.IDimg;
		var IDslide=event.data.IDslide;
		var c_direction=event.data.Direction;
		
		var elements=$JQ('#'+IDimg+' 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;
		}
		
		if(c_active>=0 && c_active<elements.length){ $JQ(elements).eq(c_active).click(); }
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_Direction: ' + err); }}
}




function jSliderMVB_ImgOver(event){
	try{
	
		$JQ(this).attr('class','over');
		$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:400, queue:false, complete:function(){     }});
		
		$JQ(this).animate({ borderBottomColor:'#ffffff'},{easing:"swing",duration:100, queue:false, complete:function(){
			if($JQ(this).attr('class')!='over'){ return false; }
			$JQ(this).animate({ borderLeftColor:'#ffffff'},{easing:"swing",duration:100, queue:false, complete:function(){
				if($JQ(this).attr('class')!='over'){ return false; }
				$JQ(this).animate({ borderTopColor:'#ffffff'},{easing:"swing",duration:100, queue:false, complete:function(){
					if($JQ(this).attr('class')!='over'){ return false; }
					$JQ(this).animate({ borderRightColor:'#ffffff'},{easing:"swing",duration:100, queue:false, complete:function(){ return false; }});
				}});
			}});
		}});
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_ImgOver: ' + err); }}
}

function jSliderMVB_ImgOut(event){
	try{ 
		//var IDimg=event.data.IDimg;
		var c_class=$JQ(this).parent().attr('class');
		if(c_class=='active'){ return false; }
		
		$JQ(this).attr('class','out');
		$JQ(this).find('img').eq(0).animate({ opacity:0.5 },{easing:"swing",duration:400, queue:false, complete:function(){     }});
		$JQ(this).animate({ borderBottomColor:'#484848'},{easing:"swing",duration:100, queue:false, complete:function(){
			if($JQ(this).attr('class')!='out'){ return false; }    
			$JQ(this).animate({ borderLeftColor:'#484848'},{easing:"swing",duration:100, queue:false, complete:function(){
				if($JQ(this).attr('class')!='out'){ return false; }
				$JQ(this).animate({ borderTopColor:'#484848'},{easing:"swing",duration:100, queue:false, complete:function(){
					if($JQ(this).attr('class')!='out'){ return false; }
					$JQ(this).animate({ borderRightColor:'#484848'},{easing:"swing",duration:100, queue:false, complete:function(){ return false; }});
				}});
			}});
		}});
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB_ImgOut: ' + err); }}
}

function jSliderMVB(IDprev1, IDprev2, IDnext1, IDnext2, IDimg, IDslide){
	try{ 
		if(!IDprev1 || IDprev1==''){ return false; }
		if(!IDnext1 || IDnext1==''){ return false; }
		if(!IDprev2 || IDprev2==''){ return false; }
		if(!IDnext2 || IDnext2==''){ return false; }
		if(!IDimg || IDimg==''){ return false; }
		if(!IDslide || IDslide==''){ return false; }
		
		
		var c_total=$JQ('#'+IDimg+' li').length; //setWidth IMG
		var c_width=parseInt($JQ('#'+IDimg+' li').eq(0).attr('offsetWidth'));
		var c_height=parseInt($JQ('#'+IDimg+' li').eq(0).attr('offsetHeight'));
		if(c_total<=0 || c_width<=0){ return false; }
		
		$JQ('#'+IDimg).find('ul').eq(0).css('width',parseInt(c_total*c_width));
		$JQ('#'+IDimg).find('ul').eq(0).css('left',0);
		
		//alert($JQ('#'+IDimg).find('ul').eq(0).css('left'));
		
		$JQ('#'+IDimg).find('a').bind("mouseenter", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide}, jSliderMVB_ImgOver);
		$JQ('#'+IDimg).find('a').bind("mouseleave", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide}, jSliderMVB_ImgOut);
		
		//$JQ('#'+IDimg).find('li').eq(0).attr('class','active');
		//$JQ('#'+IDimg).find('a').mouseleave();
		//$JQ('#'+IDimg).find('a').eq(0).mouseenter();
		
		
		
		var elements=$JQ('#'+IDimg).find('a');
		var c_href;
		
		
		$JQ('#'+IDslide).html('<ul><li></li></ul>');
		var c_width2=parseInt($JQ('#'+IDslide+' li').eq(0).attr('offsetWidth'));
		$JQ('#'+IDslide).html('<ul></ul>');
		$JQ('#'+IDslide+' ul').css('width',parseInt(c_total*c_width2));
		$JQ('#'+IDslide+' ul').css('left',0);
		
		/*
		for(var i=0;i<elements.length;i++){
			c_href=$JQ(elements).eq(i).attr('href');
			$JQ('#'+IDslide+' ul').append('<li></li>');
			if(i==0){ jSliderMVBajaxIMG($JQ('#'+IDslide).find('li').eq(i),c_href,IDimg); }
			else{ jSliderMVBajaxIMG($JQ('#'+IDslide).find('li').eq(i),c_href); }
		}
		*/
		
		var ArrayThis = new Array();
		var ArrayHref = new Array();
		
		for(var i=0;i<elements.length;i++){
			c_href=$JQ(elements).eq(i).attr('href');
			$JQ('#'+IDslide+' ul').append('<li></li>');
			ArrayThis[i]=$JQ('#'+IDslide).find('li').eq(i);
			ArrayHref[i]=c_href;
		}
		
		
		
		
		var elements=$JQ('#'+IDimg).find('li');
		$JQ(elements).attr('class','');
		$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", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide, LINKindex:i}, jSliderMVB_Set);
		}
		//alert('test');
		$JQ('#'+IDprev1).bind("click", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide, Direction:'prev'}, jSliderMVB_DirectionSlider);
		$JQ('#'+IDnext1).bind("click", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide, Direction:'next'}, jSliderMVB_DirectionSlider);
		
		$JQ('#'+IDprev2).bind("click", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide, Direction:'prev'}, jSliderMVB_DirectionImg);
		$JQ('#'+IDnext2).bind("click", {IDprev1:IDprev1, IDnext1:IDnext1, IDprev2:IDprev2, IDnext2:IDnext2, IDimg:IDimg, IDslide:IDslide, Direction:'next'}, jSliderMVB_DirectionImg);
		
		jItemHoverAnimation(IDprev1);
		jItemHoverAnimation(IDnext1);
		jItemHoverAnimation(IDprev2);
		jItemHoverAnimation(IDnext2);
		
		
		jSliderMVBajaxIMGsequel(ArrayThis,ArrayHref,0,IDimg);
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jSliderMVB: ' + err); }}
}

function jSliderMVBajaxIMGsequel(ArrayThis, ArrayHref, index, IDimg){
	try{
		index=parseInt(index);
		if(ArrayThis.length!=ArrayHref.length){ return false; }
		if(index>=ArrayThis.length){ return false; }
		
		if(index==0){
			for(var i=0;i<ArrayThis.length;i++){
				$JQ(ArrayThis[i]).html('<div class="jAjax_progress">Progress '+index+'/'+ArrayThis.length+'</div>');
			}
		}else{
			for(var i=0;i<ArrayThis.length;i++){
				$JQ(ArrayThis[i]).find('.jAjax_progress').eq(0).text('Progress '+index+'/'+ArrayThis.length);
			}
		}
		//if(!IDimg || IDimg==''){ IDimg=''; }
		
		//if(IDimg==''){ return false; }
		
		$JQ(ArrayThis[index]).css('opacity',0);
		$JQ(ArrayThis[index]).html('<div class="jAjax_loading">Loading. Please wait.</div>');
		$JQ(ArrayThis[index]).animate({opacity:1},{easing:"swing", queue:false,duration:900, complete:function(){    }});//animate Loading.       
		//---------------------------------
		var img = new Image();		
		$JQ(img).load(function(){
			var index_new=index+1;
			jSliderMVBajaxIMGsequel(ArrayThis,ArrayHref,index_new,IDimg); //load next slide
			$JQ(ArrayThis[index]).animate({opacity:0},{easing:"swing", queue:false,duration:900, complete:function(){
				$JQ(ArrayThis[index]).empty();
				$JQ(ArrayThis[index]).append(img);
				//if(IDimg!='' && index==0){ $JQ('#'+IDimg).find('li').eq(0).click(); }
				if(IDimg!=''){
					var elements=$JQ('#'+IDimg).find('li');
					var c_class;
					for(var i=0;i<elements.length;i++){
						c_class=$JQ(elements).eq(i).attr('class');
						if((c_class=='active') && (index==i)){ $JQ(elements).eq(i).click(); break; }
					}
				} //if 
				$JQ(ArrayThis[index]).animate({opacity:1},{easing:"easeOutBounce", queue:false,duration:1800, complete:function(){    }}); //animate
			}}); //animate
			
		}).error(function(){
			var index_new=index+1;
			jSliderMVBajaxIMGsequel(ArrayThis,ArrayHref,index_new,IDimg); //load next slide
			$JQ(ArrayThis[index]).animate({opacity:0},{easing:"swing", queue:false,duration:900, complete:function(){
				$JQ(ArrayThis[index]).html('<div class="jAjax_error">Unable to load image</div>');
				var c_height=parseInt($JQ(ArrayThis[index]).attr('offsetHeight'))-parseInt($JQ(ArrayThis[index]).css('paddingTop'))-parseInt($JQ(ArrayThis[index]).css('paddingBottom'));
				$JQ(ArrayThis[index]).animate({opacity:1, height:c_height},{easing:"easeOutBounce", queue:false,duration:1800, complete:function(){    }}); //animate
			}}); //animate
		}).attr('src',ArrayHref[index]);
		//---------------------------------									   
		   
		
	}catch(err){ if(DebugQueryMode==true){ alert(' jSliderMVBajaxIMG: '+err); }}
}

/*
function jSliderMVBajaxIMG(This,url,IDimg){
	try{
		  if(!IDimg || IDimg==''){ IDimg=''; }
		 // url='http://localhost/Klients/Gidziu/Project 54 - (Sanctuary)/graph/weddings/galleries/fun/full/img1.jpg'; 
		  //url=url.toString();
		  //url="parts/content/c_home.php";
		  //url="graph/weddings/galleries/fun/full/img1.jpg";
		  //url="graph/weddings/galleries/fun/full/c_home.php";
		  $JQ.ajax({
			 url: url,
			 //global: false,
			 cache: false,
			// contentType:"text/plain; Charset=UTF-8",
			 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('<img src="'+url+'" alt="" />');
					
					
					$JQ(This).attr('src',url);
					//$JQ(This).html(data);
					//$JQ(This).html('<div class="jAjax_loading">Loaded: '+url+'</div>');
					
					//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:"easeOutBounce", queue:false,duration:1800, complete:function(){ $JQ(This).css('height','auto');  }});
					$JQ(This).animate({opacity:1},{easing:"easeOutBounce", queue:false,duration:1800, complete:function(){ if(IDimg!=''){ $JQ('#'+IDimg).find('li').eq(0).click(); }  }});
				}}); //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 image</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:"easeOutBounce", queue:false,duration:1800, complete:function(){    }}); //animate
				}}); //animate
			 }
		  });
	}catch(err){ if(DebugQueryMode==true){ alert(' jSliderMVBajaxIMG: '+err); }}
}
*/
/* =============================== .SliderMVB [END] ================================= */
/* =============================== .FRMA [START] ==================================== */
function jFrmaHoverAnimation(ID){
	try{ 
		if(!ID || ID==''){ return false; }
		$JQ('#'+ID+' img').css('opacity',0);
		$JQ('#'+ID+' img').css('visibility','visible');
		
		if($JQ('#'+ID).parent().attr('class')=='frma_img'){ 
			$JQ('#'+ID).parent().prepend('<div class="frma_hover"></div>');
			$JQ('#'+ID).parent().find('.frma_hover').eq(0).css('opacity',0);
			$JQ('#'+ID).parent().find('.frma_hover').eq(0).css('visibility','visible');
		}
		
		
		$JQ('#'+ID).hover(function(){
			$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:600, queue:false, complete:function(){ /**/  }});
			if($JQ(this).parent().attr('class')=='frma_img'){
				$JQ(this).parent().find('.frma_hover').eq(0).animate({ opacity:1 },{easing:"swing",duration:600, queue:false, complete:function(){ /**/  }});
			}
			
		},function(){
			$JQ(this).find('img').eq(0).animate({ opacity:0 },{easing:"swing",duration:600, queue:false, complete:function(){ /**/  }});
			if($JQ(this).parent().attr('class')=='frma_img'){
				$JQ(this).parent().find('.frma_hover').eq(0).animate({ opacity:0 },{easing:"swing",duration:600, queue:false, complete:function(){ /**/  }});
			}
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jFrmaHoverAnimation: ' + err); }}
}
/* =============================== .FRMA [END] ====================================== */
/* =============================== .single [START] ================================== */
;(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 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:2000} );
			
			var c_left1=parseInt($JQ('#top_text').css('left'));
			var c_left2=parseInt($JQ('#top_link').css('left'));
			//var c_left3=parseInt($JQ('#top_text3').css('left'));
			
			$JQ('#top_text').css('left',c_left1+1500);
			$JQ('#top_link').css('left',c_left2+1500);
			//$JQ('#top_text3').css('left',c_left3+1500);
			
			$JQ('#top_text').css('visibility','visible');
			$JQ('#top_link').css('visibility','visible');
			//$JQ('#top_text3').css('visibility','visible');
		}
		
		switch(ID){
			case 'top_text': ID='top_link'; c_left=c_left2; break;
			case 'top_link': ID='top_text3'; c_left=c_left3; break;
			//case 'top_text3': return true; break;
			default: ID='top_text'; 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(jDebugMode==true){ alert('jTopAnimation: ' + err); }}
}


function jItemHoverAnimation(ID){
	try{ 
		if(!ID || ID==''){ return false; }
		$JQ('#'+ID+' img').css('opacity',0);
		$JQ('#'+ID+' img').css('visibility','visible');
		
		$JQ('#'+ID).hover(function(){
			$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:300, queue:false, complete:function(){ /**/  }});
		},function(){
			$JQ(this).find('img').eq(0).animate({ opacity:0 },{easing:"swing",duration:300, queue:false, complete:function(){ /**/  }});
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jItemHoverAnimation: ' + err); }}
}

function jItemHoverAnimationREL(REL){
	try{ 
		if(!REL || REL==''){ return false; }
		var elements=$JQ("a[rel$='"+REL+"']");
		$JQ(elements).find('img').css('opacity',0);
		$JQ(elements).find('img').css('visibility','visible');

		$JQ(elements).hover(function(){
			$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:300, queue:false, complete:function(){ /**/  }});
		},function(){
			$JQ(this).find('img').eq(0).animate({ opacity:0 },{easing:"swing",duration:300, queue:false, complete:function(){ /**/  }});
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jItemHoverAnimationREL: ' + err); }}
}



function jItemTipAnimation(ID, IDtip){
	try{ 
		if(!ID || ID==''){ return false; }
		if(!IDtip || IDtip==''){ return false; }
		$JQ('#'+IDtip).css('opacity',0);
		$JQ('#'+IDtip).css('display','none');
		
		//jQuery.data(document.body, "test", { first: 16, last: "pizza!", rets:"it works" });
		jQuery.data(document.body, ID, { s_id1: ID, s_id2: IDtip});
		jQuery.data(document.body, IDtip, { s_id1: ID, s_id2: IDtip});
		//var e = event.data.someData;
		
		$JQ('#'+ID).hover(function(){
			var c_id=jQuery.data(document.body, $JQ(this).attr('id')).s_id2;
			$JQ('#'+c_id).css('display','block');
			$JQ('#'+c_id).animate({ opacity:1 },{easing:"swing",duration:500, queue:false, complete:function(){ /**/  }});
		},function(){	});
		
		
		
		$JQ('#'+IDtip).hover(function(){
			jQuery.data(document.body, $JQ(this).attr('id'), { s_active:true });
			//var c_id=jQuery.data(document.body, $JQ(this).attr('id')).s_id2;
			//$JQ(this).css('display','block');
			$JQ(this).animate({ opacity:1 },{easing:"swing",duration:500, queue:true, complete:function(){ $JQ(this).css('display','block');  }});
		},function(){
			jQuery.data(document.body, $JQ(this).attr('id'), { s_active:false });
			$JQ(this).animate({ opacity:0 },{easing:"swing",duration:500, queue:false, complete:function(){ 
				if(jQuery.data(document.body, $JQ(this).attr('id')).s_active==false){
					$JQ(this).css('display','none');
				}
			}});
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jItemTipAnimation: ' + err); }}
}

function jFootAnimation(IDmain, IDfoot){
	try{ 
		if(!IDmain || IDmain==''){ return false; }
		if(!IDfoot || IDfoot==''){ return false; }
		
		$JQ('#'+IDmain).css('min-height',0);
		
		var c_Hfoot=parseInt($JQ('#'+IDfoot).attr('offsetHeight'));
		$JQ('#'+IDfoot).css('opacity',0);
		$JQ('#'+IDfoot).css('margin-top',c_Hfoot*(-1));
		$JQ('#'+IDmain).css('padding-bottom',c_Hfoot);
		
		var c_Hbody=parseInt($JQ(document).height())-parseInt($JQ(document.body).height());
		var c_Hmain=parseInt($JQ('#'+IDmain).attr('offsetHeight'));// - parseInt($JQ('#'+IDmain).css('paddingTop')) - parseInt($JQ('#'+IDmain).css('paddingBottom'));
		var c_PGmain=parseInt($JQ('#'+IDmain).css('paddingTop'))+ parseInt($JQ('#'+IDmain).css('paddingBottom'));
		
		if(c_Hbody>=0){
			$JQ('#'+IDmain).css('min-height',parseInt(parseInt($JQ(document).height())-c_PGmain));
			$JQ('#'+IDfoot).animate({ opacity:1 },{easing:"swing",duration:3500, queue:false, complete:function(){     }});
		}
	}catch(err){ if(jDebugMode==true){ alert('jFootAnimation: ' + err); }}
}



$JQ(document).ready(function(){
	//jTopAnimation();
	//jMenuAnimation('menul');
	jItemHoverAnimation('top_logo');
	jItemHoverAnimation('top_logo2');
	jItemTipAnimation('top_abia','top_tipabia');
	jItemHoverAnimation('info_1');
	jItemHoverAnimation('info_2');
	jItemHoverAnimation('info_3');
	jItemHoverAnimation('info_4');
	jItemHoverAnimation('info_5');
	jFootAnimation('main_container','foot');
	
});
/* =============================== .single [END] ==================================== */
/* =============================== .Disabled [START] ================================ */
/*
function jAjaxClearboxCleaner(){
	try{
		var elements=$JQ('.jAjaxDone').find('a');
		for(i=0;i<elements.length;i++){
			c_rev=$JQ(elements).eq(i).attr('rev');
			if(c_rev.toLowerCase()=='clearbox'){
				$JQ(elements).eq(i).click(function () { return false; });
			}
		}
		
		setBlur();
		
	}catch(err){ if(DebugQueryMode==true){ alert('jAjaxClearboxCleaner: '+err); }}
}
*/
/* =============================== .Disabled [END] ================================== */
/* ================================================================================== */
/* =============================== jquery.ready [END] =============================== */
/* ================================================================================== */
