//	document ready events
$(document).ready(function(){
	//	menu
	load_menu ();
        //	dialogs, moved from thickbox, just a humble hack
        load_dialog_hack ();
        //	datepickers
        load_datepickers ();
        //	autocomplete
        load_autocomplete ();
});
//	--> document ready events

function load_datepickers ()
{
	jQuery('.datepicker').datepicker({showOn: 'both',dateFormat: 'mm/dd/yy', buttonImage: base_url + 'templates/' +active_template + '/images/icons/calendar.gif', buttonImageOnly: true});
}
function close_dialog (el_id)
{
	$('#' + el_id).dialog("close");
}
function load_menu ()
{
	jQuery('ul.sf-menu').superfish({ 
		delay:       500,
		speed:       'fast',
		autoArrows:  true,
		dropShadows: true
        });//	--> end menu
}
function load_autocomplete ()
{
	$('.autocomplete').each(function(){
		var url = this.title;
		var el = $(this).attr("id");
		var el_id = document.getElementById(el);
		$(this).suggest(url);
	});
}
function load_dialog_hack ()
{
	jQuery('a.thickbox, area.thickbox, input.thickbox').click(function(){
        	var full_url = (isset(this.href)) ? this.href : null;
		var url = full_url.split('#KeepThis');
        	var t = this.title || this.name || '&nbsp;';
		var dialog_wrapper = '#wb_dialog';

		if (url!==null)
		{
			//	get the page size and other params
			var params = tb_parseQuery(full_url);
			
			if(params['refresh']!='undefined' && params['refresh'] == 'true') {
				jQuery(dialog_wrapper).bind('dialogclose', function(event) {
				     document.location = document.location;
				});
			}
			else {
				jQuery(dialog_wrapper).bind('dialogclose', function(event) {
				     jQuery(dialog_wrapper).remove ();
				     jQuery("#dialog").remove ();
				     jQuery(".ui-dialog").remove ();
				     jQuery('<div id="wb_dialog"></div>').appendTo("#autocompleter-loading")
				});
			}
	
			TB_WIDTH = (params['width']*1) || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) || 440; //defaults to 440 if no paramaters were added to URL

			if(valid_url(url[0]))
			{
				jQuery(dialog_wrapper).html("<iframe frameborder='0' hspace='0' src='"+url[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' style='padding:0!important;margin:0!important;width:100%;height:100%;' ></iframe>");
			}
			else {
				var getid = url[0].split('#');
				var dialog_wrapper = '#'+getid[1];
			}
			
			jQuery(dialog_wrapper).css({ margin:0,padding:0,overflow:"auto"});

			jQuery(dialog_wrapper).dialog({
				modal: params['modal'],
				height:TB_HEIGHT,
				width:TB_WIDTH,
				title:t,
				overlay: {
					opacity: 0.5,
					background: "#15202B"
				} 
			});
			$(dialog_wrapper).show();
		}

        	this.blur();
		return false;
        });//	--> end dialogs
}
function isset(v){
	if (v == undefined)
	{
		return false;
	}
	return true;
}
function valid_url(url) {
	var v = new RegExp();
	v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+[\\.|localhost][A-Za-z0-9-_%&\?\/.=]+$");
	if (!v.test(url)) {
		return false;
	}
	return true;
} 
function load_inline_dialog (target,height,width,title,modal)
{
	jQuery(target).dialog({
		modal: modal,
		height:height,
		width:width,
		title:title,
		overlay: {
			opacity: 0.5,
			background: "white"
		} 
	});

	return true;
}
function load_iframe_dialog (url,height,width,title,modal)
{
	var dialog_wrapper = '#dialog_wrapper';
	jQuery(dialog_wrapper).html("<iframe frameborder='0' hspace='0' src='"+url+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' style='padding:0!important;margin:0!important;width:100%;height:100%;' ></iframe>");
	jQuery(dialog_wrapper).dialog({
		modal: modal,
		height:height,
		width:width,
		title:title,
		overlay: {
			opacity: 0.5,
			background: "#15202B"
		} 
	});
	$(dialog_wrapper).show();

	this.blur();
	return false;
}
function tb_parseQuery ( query ) {
	var Params = {};
	if ( ! query ) {return Params;}// return empty object
	var Pairs = query.split(/[;&]/);
	for ( var i = 0; i < Pairs.length; i++ ) {
		var KeyVal = Pairs[i].split('=');
		if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
		var key = unescape( KeyVal[0] );
		var val = unescape( KeyVal[1] );
		val = val.replace(/\+/g, ' ');
		Params[key] = val;
	}
	return Params;
}

var btn = {
	init : function() {
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		as = btn.getElementsByClassName('btn(.*)');
		for (i=0; i<as.length; i++) {
			if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) ) {
				var tt = document.createTextNode(as[i].value);
				var a1 = document.createElement("a");
				a1.className = as[i].className;
				a1.id = as[i].id;
				as[i] = as[i].parentNode.replaceChild(a1, as[i]);
				as[i] = a1;
				as[i].style.cursor = "pointer";
			}
			else if (as[i].tagName == "A") {
				var tt = as[i].firstChild;
			}
			else { return false };
			var i1 = document.createElement('i');
			var i2 = document.createElement('i');
			var s1 = document.createElement('span');
			var s2 = document.createElement('span');
			s1.appendChild(i1);
			s1.appendChild(s2);
			s1.appendChild(tt);
			as[i].appendChild(s1);
			as[i] = as[i].insertBefore(i2, s1);
		}

	},
	findForm : function(f) {
		while(f.tagName != "FORM") {
			f = f.parentNode;
		}
		return f;
	},
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener) {
			obj.addEventListener(type, fn, false);
		}
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	},
	getElementsByClassName : function(className, tag, elm) {
		var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
		var tag = tag || "*";
		var elm = elm || document;
		var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
		var returnElements = [];
		var current;
		var length = elements.length;
		for(var i=0; i<length; i++){
			current = elements[i];
			if(testClass.test(current.className)){
				returnElements.push(current);
			}
		}
		return returnElements;
	}
}

btn.addEvent(window,'load', function() { btn.init();} );
function ShowTab(T)
{
	if (TabSize != null) {
		maxSize = TabSize + 1;
	} else {
		maxSize = 7;
	}

	for(i = 1; i < maxSize; i++)
	{
		document.getElementById("div" + i).style.display = "none";
		document.getElementById("tab" + i).className = "";
	}
	
	document.getElementById("div" + T).style.display = "";
	document.getElementById("tab" + T).className = "active";
}
function ShowAll(T)
{
	if (TabSize != null) {
		maxSize = TabSize;
	} else {
		maxSize = 7;
	}

	for(i = 1; i < maxSize; i++)
	{
		document.getElementById("div" + i).style.display = "block";
		document.getElementById("tab" + i).className = "";
	}
	
}
function myPopup(link,width,height) {
	return window.open( link, "myWindow", "status = 1, height = " + height + ", width = " + width + ", resizable = 1" );
}
function makeactive(tab)
{
	document.getElementById("tab1").className = "tab";
	document.getElementById("tab2").className = "tab";
	document.getElementById("tab3").className = "tab";
	document.getElementById("tab"+tab).className = "tab selected";
}
function SelectOptions(id)
{
	var rel = document.getElementById(id);
	for (i=0; i < rel.options.length; i++) {
		rel.options[i].selected = true;
	}
}
function hidediv(id) {
	if (document.getElementById) {
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) {
			document.id.display = 'none';
		}
		else {
			document.all.id.style.display = 'none';
		}
	}
}
function showdiv(id) {
	if (document.getElementById) {
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) {
			document.id.display = 'block';
		}
		else {
			document.all.id.style.display = 'block';
		}
	}
}
function MM_jumpMenu(targ,selObj,restore){eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");if (restore) selObj.selectedIndex=0;}
function mark_options(id, s)
{
	var t = document.getElementById(id);
	
	if (!t)
	{
		return;
	}
	
	var rb = t.getElementsByTagName('input');
	
	for (var r = 0; r < rb.length; r++)
	{
		if (rb[r].id.substr(rb[r].id.length-1) == s)
		{
			rb[r].checked = true;
		}
	}
}
function CheckUncheckAll(frmID){
	var t = document.getElementById(frmID);

	if (!t)
	{
		return;
	}
	count = t.elements.length;
	for (i=0; i < count; i++) 
	{
		if(t.elements[i].checked == 1) {
			t.elements[i].checked = 0;
		}
		else {
			t.elements[i].checked = 1;
		}
	
	}
	
}
function hideTour(link)
{
	Amberjack.close();
	document.location = link;
}

function startTour(start_url)
{
	document.location = start_url;
}
function ajax_form(form,site_url,link_id){
	jQuery('#' + link_id).slideUp("slow");
	showUpdate();
	var req = jQuery.post
	( 
		site_url, 
		jQuery('#' + form).serialize(), 
		function(html){
			jQuery('#' + link_id).html(html);
			jQuery('#' + link_id).slideDown("slow");
			hideUpdate();
			req = null;
		}
	);
}

function ajax_form_redir(form,site_url,redir_url){
	showUpdate();
	var req = jQuery.post
	( 
		site_url, 
		jQuery('#' + form).serialize(), 
		function(html){
			document.location = redir_url
		}
	);
}
function wb_update_user_language (post_url)
{	showUpdate();
	var req = jQuery.post
	( 
		post_url, 
		jQuery('#user_selected_lang_frm').serialize(), 
		function(){
			hideUpdate();
			req = null;
		}
	);
}
function ajax_load_content (url,receiver){return jQuery('#' . receiver).load(url);}
//	show the "loading" bar and prevent any other interaction with the page
function showUpdate() {
	var tb_pathToImage = base_url + "templates/" + active_template + "/images/loadingAnimation.gif";
	var half_w_width = ($(window).width()/2)-104;
	var half_w_height = $(window).height()/2;

	$('<div id="loading-overlay"></div>').appendTo(document.body)
	.css({
		borderWidth: 0, margin: 0, padding: 0,
		position: 'fixed', top: 0, left: 0,
		background:'#ffffff',
		opacity:0.2,
		'z-index':9999,
		width: browser_width(),
		height: browser_height()
	});

	$('<div id="loading-bar"></div>').appendTo(document.body)
	.css({
		borderWidth: 0, margin: 0, padding: 0,
		position: 'fixed', top: half_w_height, left: half_w_width,
		width:'208px',
		height:'13px',
		opacity:1,
		'z-index':9999,
		backgroundImage:'url('+tb_pathToImage+')',
		backgroundRepeat:'no-repeat',
		backgroundPosition:'0 0'
	});
}

//	hide the "loading" bar
function hideUpdate() {
	$("#loading-overlay").remove();
	$("#loading-bar").remove();
}
//	returns the browser's width measures
function browser_width(){
	if ($.browser.msie && $.browser.version < 7) {
		var scrollWidth = Math.max(
			document.documentElement.scrollWidth,
			document.body.scrollWidth
		);
		var offsetWidth = Math.max(
			document.documentElement.offsetWidth,
			document.body.offsetWidth
		);
		
		if (scrollWidth < offsetWidth) {
			return $(window).width();
		} else {
			return scrollWidth;
		}
	} else if ($.browser.opera) {
		return Math.max(
			window.innerWidth,
			$(document).width()
		);
	} else {
		return $(document).width();
	}
}
//	returns the browser's height measures
function browser_height(){
	if ($.browser.msie && $.browser.version < 7) {
		var scrollHeight = Math.max(
			document.documentElement.scrollHeight,
			document.body.scrollHeight
		);
		var offsetHeight = Math.max(
			document.documentElement.offsetHeight,
			document.body.offsetHeight
		);
		
		if (scrollHeight < offsetHeight) {
			return $(window).height();
		} else {
			return scrollHeight;
		}
	} else if ($.browser.opera) {
		return Math.max(
			window.innerHeight,
			$(document).height()
		);
	} else {
		return $(document).height();
	}
}
jQuery(function(){jQuery('.tooltip').tooltip({track: true,delay: 2,showURL: false,showBody: " - "});});
function jquery_slide_down(el_id){jQuery('#' + el_id).slideDown("slow");}
function jquery_slide_up(el_id){jQuery('#' + el_id).slideUp("slow");}
function jquery_toggle(el_id){jQuery('#' + el_id).slideToggle("slow");}
function update_cart(coupon) {
	var link_id = 'purchase_table';
	var form = 'purchase_form';
	jQuery('#' + link_id).slideUp("slow");
	showUpdate();
	var req = jQuery.post
	( 
		update_cart_url, 
		jQuery('#' + form).serialize(), 
		function(html){
			jQuery('#' + link_id).html(html);
			jQuery('#' + link_id).slideDown("slow");
			hideUpdate();
			req = null;
		}
	);
}
function add_class(el_id,el_class){return jQuery('#' + el_id).addClass(el_class);}
function rem_class(el_id,el_class){return jQuery('#' + el_id).removeClass(el_class);}

(function($){
$.fn.bgIframe = $.fn.bgiframe = function(s) {
	// This is only for IE6
	if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
		s = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, s || {});
		var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
			html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
					   'style="display:block;position:absolute;z-index:-1;'+
						   (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
						   'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
						   'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
						   'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
						   'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
					'"/>';
		return this.each(function() {
			if ( $('> iframe.bgiframe', this).length == 0 )
				this.insertBefore( document.createElement(html), this.firstChild );
		});
	}
	return this;
};
})(jQuery);

$(function() {
	$('.childs').bgiframe();
});

//typewatch
jQuery.fn.extend({
	typeWatch:function(options) {
		waitTextbox(this, options);
	}
});

function waitTextbox(element, options) {
	element.each(
	
		function() {
		
			// Set to current element
			thisEl = jQuery(this);
			var winSaved = "typewatch_" + typewatch_uid++;
			var objWatch = {timer:null, text:null, cb:null, el:null, wait:null};

			// Create js prop
			this.typewatchid = winSaved;

			// Must be text or textarea
			if (this.type.toUpperCase() == "TEXT" 
				|| this.nodeName.toUpperCase() == "TEXTAREA") {

				// Allocate timer element
				window[winSaved] = objWatch;
				var timer = window[winSaved];
				
				// Defaults
				var _wait = 750;
				var _callback = function() { };
				var _highlight = true;
				var _captureEnter = true;

				// Get options
				if (options) {
					if(options["wait"] != null) _wait = parseInt(options["wait"]);
					if(options["callback"] != null) _callback = options["callback"];
					if(options["highlight"] != null) _highlight = options["highlight"];
					if(options["enterkey"] != null) _captureEnter = options["enterkey"];
				}

				// Set values
				timer.text = thisEl.val().toUpperCase();
				timer.cb = _callback;
				timer.wait = _wait;
				timer.el = this;

				// Set focus action (highlight)
				if (_highlight) {
					thisEl.focus(
						function() {
							this.select();
						});
				}

				// Key watcher / clear and reset the timer
				thisEl.keydown(
					function(evt) {
						var thisWinSaved = this.typewatchid;
						var timer = window[thisWinSaved];
						
						// Enter key only on INPUT controls
						if (evt.keyCode == 13 && this.type.toUpperCase() == "TEXT") {
							clearTimeout(timer.timer);
							timer.timer = setTimeout('typewatchCheck("' + thisWinSaved + '", true)', 1);							
							return false;
						}
						
						clearTimeout(timer.timer);
						timer.timer = setTimeout('typewatchCheck("' + thisWinSaved + '", false)', timer.wait);
					});
			}
		});
}

function typewatchCheck( thisWinSaved, override ) {
	var timer = window[thisWinSaved];
	var elTxt = $(timer.el).val();

	// Fire if text > 2 AND text != saved txt OR if override AND text > 2
	if ((elTxt.length > 0 && elTxt.toUpperCase() != timer.text) || (override && elTxt.length > 0)) {
		timer.text = elTxt.toUpperCase();
		timer.cb(elTxt);
	}
}

var typewatch_uid = 0; // unique counter

//forms highlight
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3(7.X){7["R"+a]=a;7["z"+a]=6(){7["R"+a](7.1k)};7.X("1e",7["z"+a])}E{7.19("z",a,15)}2 j=H V();6 a(){2 e=q.1d("1a");3(e){o(e,"P");2 N=B(q,"*","14");3((e.12<=10)||(N=="")){c(e,"P",d)}}4=B(q,"*","1n");k(i=0;i<4.b;i++){3(4[i].F=="1g"||4[i].F=="1f"||4[i].F=="1c"){4[i].1b=6(){r();c(v.5.5,"f",d)};4[i].O=6(){r();c(v.5.5,"f",d)};j.D(j.b,0,4[i])}E{4[i].O=6(){r();c(v.5.5,"f",d)};4[i].18=6(){o(v.5.5,"f")}}}2 C=17.16.13();2 A=q.M("11");3(C.K("J")+1){c(A[0],"J",d)}3(C.K("I")+1){c(A[0],"I",d)}}6 r(){k(2 i=0;i<j.b;i++){o(j[i].5.5,"f")}}6 B(m,y,w){2 x=(y=="*"&&m.Y)?m.Y:m.M(y);2 G=H V();w=w.1m(/\\-/g,"\\\\-");2 L=H 1l("(^|\\\\s)"+w+"(\\\\s|$)");2 n;k(2 i=0;i<x.b;i++){n=x[i];3(L.1j(n.8)){G.1i(n)}}1h(G)}6 o(p,T){3(p.8){2 h=p.8.Z(" ");2 U=T.t();k(2 i=0;i<h.b;i++){3(h[i].t()==U){h.D(i,1);i--}}p.8=h.S(" ")}}6 c(l,u,Q){3(l.8){2 9=l.8.Z(" ");3(Q){2 W=u.t();k(2 i=0;i<9.b;i++){3(9[i].t()==W){9.D(i,1);i--}}}9[9.b]=u;l.8=9.S(" ")}E{l.8=u}}',62,86,'||var|if|elements|parentNode|function|window|className|_16|initialize|length|addClassName|true|_1|highlighted||_10||el_array|for|_13|_6|_c|removeClassName|_e|document|safari_reset||toUpperCase|_14|this|_8|_9|_7|load|_4|getElementsByClassName|_3|splice|else|type|_a|new|firefox|safari|indexOf|_b|getElementsByTagName|_2|onfocus|no_guidelines|_15|event_load|join|_f|_11|Array|_17|attachEvent|all|split|450|body|offsetWidth|toLowerCase|guidelines|false|userAgent|navigator|onblur|addEventListener|main_body|onclick|file|getElementById|onload|radio|checkbox|return|push|test|event|RegExp|replace|element'.split('|'),0,{}));

function toggleRadion(id,option) {
	jQuery("input[class='" + id + "_y']").attr('checked',option);
	jQuery("input[class='" + id + "_n']").attr('checked',!option);
}

function products_delete_prod_role(id, prod_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ id: id, prod_id: prod_id },
		function(data){
			jQuery('#list_' + prod_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_delete_discount_product(discount_id, product_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ discount_id: discount_id, product_id: product_id },
		function(data){
			jQuery('#products_list_' + discount_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_delete_coupon_role(coupon_id, role_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ coupon_id: coupon_id, role_id: role_id },
		function(data){
			jQuery('#roles_list_' + coupon_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_delete_coupon_product(coupon_id, product_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ coupon_id: coupon_id, product_id: product_id },
		function(data){
			jQuery('#products_list_' + coupon_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_change_coupon_status(coupon_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ coupon_id: coupon_id },
		function(data){
			jQuery('#coupon_status_' + coupon_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_activate_discount(discount_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ discount_id: discount_id },
		function(data){
			jQuery('#discount_status_' + discount_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_activate_coupon(coupon_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ coupon_id: coupon_id },
		function(data){
			jQuery('#coupon_status_' + coupon_id).html(data);
			hideUpdate(); 
		}
	);
}

function products_get_product_roles(product, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ product: product },
		function(data){
			spl_data = data.split('---//---');
			jQuery('#user_group').html(spl_data[0]);
			jQuery('#amount').val(spl_data[1]);
			hideUpdate(); 
		}
	);
}

function cron_job_change_status(cron_job_id, call_url) {
	showUpdate();
	jQuery.post(call_url, 
		{ cron_job_id: cron_job_id },
		function(data){
			jQuery('#cron_job_status_' + cron_job_id).html(data);
			hideUpdate(); 
		}
	);
}

function confirm_delete(delUrl) {
  if (confirm('Are you sure you want to delete this?')) {
    if ( delUrl != null) document.location = delUrl;
  }
}

/**
 * Adds text to a given textarea, used at mass mail
 **/
function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}
function preview_mass_mail(url){
	jQuery('#preview_mail').show('slow');
	jQuery('#mass_email_form').attr("target",'preview_ifrm');
	jQuery('#mass_email_form').attr("action",url);
}
function reset_mass_mail_target(url){
	jQuery('#preview_mail').hide('slow');
	jQuery('#mass_email_form').attr("target",'');
	jQuery('#mass_email_form').attr("action",url);
}