$(document).ready(function() { 
	$('a.modal').nyroModal({
		bgColor: '#999999',
		minWidth: 350,
		minHeight: 0
	});	
    
	$(document).pngFix();
});


function createNewListModal(id)
{
	$(function() {
	    $.nyroModalManual({
	      url: '/newsletter/createMailinglist?newsletter_id='+id,
		  bgColor: '#999999',
		  minWidth: 350,
		  minHeight: 0
	    });
	    
	    return false;
    });
}


// Initiate TinyMCE interface
function initTinyMce(elements, type) {

	if(type == 'advanced') {
		
		tinyMCE_GZ.init({
			plugins : 'imagemanager,spellchecker,inlinepopups,advimage,fullscreen,advlink,preview,media,searchreplace,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras',
			themes : 'advanced',
			languages : 'en',
			disk_cache : true,
			convert_urls : false,
			debug : false
		});
		
		tinyMCE.init({
			mode : "exact",
			elements : elements,
			theme : "advanced",
			convert_urls : false,
			// plugins : "table,imagemanager,spellchecker,inlinepopups,fullscreen,advimage,advlink,preview,media,advhr,searchreplace,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras",
			plugins : "table,spellchecker,inlinepopups,fullscreen,advimage,advlink,preview,media,advhr,searchreplace,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,bullist,numlist,|,formatselect,fontsizeselect,pastetext,pasteword",
			theme_advanced_buttons2 : "outdent,indent,|,undo,redo,|,link,unlink,cleanup,code,|,forecolor,backcolor,sub,sup,|,charmap,iespell,|,ltr,rtl,|,advhr,fullscreen,media,image,|,spellchecker,table",
			theme_advanced_buttons3 : "",
			theme_advanced_blockformats : "h1,h2,h3,h4,h5,h6",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
		 	theme_advanced_resize_horizontal : false,
      forced_root_block : false,
      force_br_newlines : true,
      force_p_newlines : false,
  		extended_valid_elements : "object[type|src|id|pluginspage|bgcolor|allowScriptAccess|allowFullScreen|quality|name|play|scale|menu|salign|scriptAccess|wmode|height|width|flashvars],embed[type|src|id|pluginspage|bgcolor|allowScriptAccess|allowFullScreen|quality|name|play|scale|menu|salign|scriptAccess|wmode|height|width|flashvars],param[name|value],a[class|style|name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
		});

	} else if(type == 'simple') {
	
		tinyMCE_GZ.init({
			themes : 'simple',
			languages : 'en',
			disk_cache : true,
			debug : false
		});
		
		tinyMCE.init({
			mode : "exact",
			elements : elements,
			theme : "simple"
		});
	
	
	}
}

// Click to expand
$(document).ready(function()
  {
    //hide all of the element with class click-to-expand-body
    $(".click-to-expand-body").hide();
    //toggle the componenet with class click-to-expand-body
    $(".click-to-expand-head").click(function()
    {
      $(this).next(".click-to-expand-body").slideToggle(60);
    });
});

// Click to expand that partially shows hidden area
$(document).ready(function() {
  var adjustheight = 109;
  $(".expand-area-toggle").toggle(function() {
    $(this).prev().css('height', 'auto').css('overflow', 'visible');
    $(this).text("[less]");
  }, function() {
    $(this).prev().css('height', adjustheight).css('overflow', 'hidden');
    $(this).text("[more]");
  });
});