// JavaScript Document

$(document).ready(function() {
function goToByScroll(id){
     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
function close_cbox(){
	setTimeout(parent.$.colorbox.close(), 1500);
}
var modal_update = false;
function update_modal(){
	modal_update = true;
}
function show_loading(){
	var w = $(window).width();
	var h = $(window).height();
	$(".modal_loader").css("width", w+'px').css("height", h+'px').show();
}
function reload_page(){
	show_loading();
	window.location = document.location.href;
}
$('.mc_ajax').click(function(e) {
	e.preventDefault();
	var url = $(this).attr('href');
	 $.ajax({  
                type: "GET", 
				url: url,  
				  	complete: function(data) {
						reload_page()
						},
				});  
	});

$(".editor_btn").click(function(){
	var v = $(this).attr("id");
	$("#mc_editor").val(v);
	$("#frm_editPage").submit();
	});
$(".mc_modal").colorbox({
iframe:true, 
innerWidth:'90%', 
innerHeight:'85%', 
returnFocus:true, 
fastIframe:false, 
overlayClose:false, 
escKey:false,
fixed: true,
onClosed:function(){ 
		//if(modal_update){
			 reload_page();
		//}
},
title:false
			});
			
 	
	/*var wrapper_height = $("#header").height();
	var wrapper_width = $("#header").width();
	var logo_wrapper_height = $("#mcLogoBox_span").height();
	$("#header_span").css("width", wrapper_width+"px");	
	$("#header_span").css("height", wrapper_height+"px");	
	
	if(wrapper_width > logo_wrapper_height){
		$("#mcLogoBox_span").css("height", wrapper_height+"px");	
	}*/

if(mc_editor_mode){
// EDITOR MODE
$('.mc_mod').mouseover(function() {
	$(this).addClass("mod_edit_highlight").find(".mod_edit_actions").show();
	});
$('.mc_mod').mouseout(function() {
	$(this).removeClass("mod_edit_highlight").find(".mod_edit_actions").hide();
	});

$('.mc_pos').mouseover(function() {
	$(this).find(".new_module").show();
	});
$('.mc_pos').mouseout(function() {
	$(this).find(".new_module").hide();
	});

$('.mod_column').mouseover(function() {
	$(this).addClass("modc_edit_highlight").find(".modc_edit_actions").show();
	});
$('.mod_column').mouseout(function() {
	$(this).removeClass("modc_edit_highlight").find(".modc_edit_actions").hide();
	});

	$(function() {
		$(".mc_pos ul").sortable({ opacity: 0.5, cursor: 'move', helper: 'helper', update: function() {
			var order = $(this).sortable("serialize") + '&action=update_order'; 
			//alert(order);
			//$.post("updateDB.php", order, function(theResponse){
				//$("#contentRight").html(order);
			//}); 															 
		}								  
		});
	});

 } //EDITOR MODE

		$(".up").click(function(){
			var id = $(this).attr("id");
			var targ = "r_" + id;
			if($("#" + targ).css("display")=='none'){
			$(this).attr("src","images/uparrow-1.png");
			$("#" + targ).slideDown("fast");
			} else {
			$("#" + targ).slideUp("fast");
			$(this).attr("src","images/downarrow-1.png");
			}
});

});
