jQuery.noConflict();

jQuery(document).ready(function(){
								
		//LOADING POPUP
	//Click the button event!
	jQuery("#button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	jQuery("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	jQuery("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	jQuery(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
						   

						   
		slideGal2(jQuery('.slide-gal5'));
		
		
		
});

		/*--- function slideGal5 ---*/
function slideGal2(gal_holders){
	gal_holders.each(function(){
		var gal_hold = jQuery(this);
		var list_hold = gal_hold.find('.container > ul');
		var btn_prev = gal_hold.find('.top');
		var btn_next = gal_hold.find('.bottom');
		var _list = list_hold.children();
		var _a = 0;
		var _m = 0;
		if(_list.length > 1) {
			//list_hold.append(list_hold.children().clone());
			
			
			
			//by mahongtao 2009/04/13 Begin
			_list.find('h3 a').each(function()
			{
			    jQuery(this).bind('click',function()
			    {
			       var stat=jQuery(this).parent().parent().find('.more-box').css('display');
			       
			       if(stat=='block')
			       {
			           return true;
			       }
			       else
			       {
			           _list.find('.more-box').hide();
			           
			           jQuery(this).parent().parent().find('.more-box').show();
			           
			           return false;
			       }
			    });
			});
			//by mahongtao 2009/04/13 End
			
			_list.eq(_a).find('.more-box').show();
			
			var t_h;
			btn_next.click(function(){
				if(!list_hold.is(':animated')){
					if(_a < _list.length - 1){
						t_h = _list.eq(_a).outerHeight();
						_list.eq(_a).find('.more-box').each(function(){
							t_h -= jQuery(this).outerHeight();
						}).slideUp(300);
						_m += t_h;
						list_hold.animate({marginTop: -_m}, 300);
						_list.eq(_a+1).find('.more-box').slideDown(300);
						_a++;
					}
//					else{
//						t_h = _list.eq(_a).outerHeight();
//						_list.eq(_a).find('.more-box').each(function(){
//							t_h -= jQuery(this).outerHeight();
//						}).slideUp(300);
//						_m += t_h;
//						list_hold.animate({marginTop: -_m}, 300);
//						list_hold.children().eq(_list.length).find('.more-box').slideDown(300, function(){
//							_a = 0;
//							_m = 0;
//							_list.eq(_a).find('.more-box').show();
//							list_hold.css('margin-top', _m);
//							list_hold.children().eq(_list.length).find('.more-box').hide();
//						});
//					}
				}
				return false;
			});
			var _f2 = false;
			btn_prev.click(function(){
				if(!list_hold.is(':animated')){
					if(_a > 0){
						t_h = _list.eq(_a).outerHeight();
						_list.eq(_a).find('.more-box').each(function(){
							t_h -= jQuery(this).outerHeight();
						}).slideUp(300);
						_m -= _list.eq(_a - 1).outerHeight();
						list_hold.animate({marginTop: -_m}, 300);
						_list.eq(_a - 1).find('.more-box').slideDown(300);
						_a--;
					}
//					else{
//						_list.eq(_a).find('.more-box').hide();
//						_list.each(function(){ _m += jQuery(this).outerHeight();});
//						list_hold.css('margin-top', -_m);
//						_a = _list.length - 1;
//						_m -= list_hold.children().eq(_list.length).outerHeight();
//						list_hold.children().eq(_list.length).find('.more-box').show().slideUp(300);
//						list_hold.animate({marginTop: -_m}, 300);
//						_list.eq(_a).find('.more-box').slideDown(300);
//					}

				}
				
				return false;
			});
		}
		else{
			_list.eq(_a).find('.more-box').show();
			btn_prev.click(function(){ return false;});
			btn_next.click(function(){ return false;});
		}
	});
}


/* popup code */

/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		jQuery("#backgroundPopup").css({
			"opacity": "0.7"
		});
		jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		jQuery("#backgroundPopup").fadeOut("slow");
		jQuery("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popupContact").height();
	var popupWidth = jQuery("#popupContact").width();
	//centering
	jQuery("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	jQuery("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

var inputText = '';

function inputFocused(DOM_OBJECT)
{
        inputText = DOM_OBJECT.value;
        DOM_OBJECT.value = "";
}
	
function inputBlurred(DOM_OBJECT)
{
        if(DOM_OBJECT.value=="") {
			 DOM_OBJECT.value = inputText;
		}

}
	
	
