/* Punkt NET - jquery_init.js */

//	PLUGIN: jquery.tooltip
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}(';(8($){j e={},9,m,B,A=$.2u.2g&&/29\\s(5\\.5|6\\.)/.1M(1H.2t),M=12;$.k={w:12,1h:{Z:25,r:12,1d:19,X:"",G:15,E:15,16:"k"},2s:8(){$.k.w=!$.k.w}};$.N.1v({k:8(a){a=$.1v({},$.k.1h,a);1q(a);g 2.F(8(){$.1j(2,"k",a);2.11=e.3.n("1g");2.13=2.m;$(2).24("m");2.22=""}).21(1e).1U(q).1S(q)},H:A?8(){g 2.F(8(){j b=$(2).n(\'Y\');4(b.1J(/^o\\(["\']?(.*\\.1I)["\']?\\)$/i)){b=1F.$1;$(2).n({\'Y\':\'1D\',\'1B\':"2r:2q.2m.2l(2j=19, 2i=2h, 1p=\'"+b+"\')"}).F(8(){j a=$(2).n(\'1o\');4(a!=\'2f\'&&a!=\'1u\')$(2).n(\'1o\',\'1u\')})}})}:8(){g 2},1l:A?8(){g 2.F(8(){$(2).n({\'1B\':\'\',Y:\'\'})})}:8(){g 2},1x:8(){g 2.F(8(){$(2)[$(2).D()?"l":"q"]()})},o:8(){g 2.1k(\'28\')||2.1k(\'1p\')}});8 1q(a){4(e.3)g;e.3=$(\'<t 16="\'+a.16+\'"><10></10><t 1i="f"></t><t 1i="o"></t></t>\').27(K.f).q();4($.N.L)e.3.L();e.m=$(\'10\',e.3);e.f=$(\'t.f\',e.3);e.o=$(\'t.o\',e.3)}8 7(a){g $.1j(a,"k")}8 1f(a){4(7(2).Z)B=26(l,7(2).Z);p l();M=!!7(2).M;$(K.f).23(\'W\',u);u(a)}8 1e(){4($.k.w||2==9||(!2.13&&!7(2).U))g;9=2;m=2.13;4(7(2).U){e.m.q();j a=7(2).U.1Z(2);4(a.1Y||a.1V){e.f.1c().T(a)}p{e.f.D(a)}e.f.l()}p 4(7(2).18){j b=m.1T(7(2).18);e.m.D(b.1R()).l();e.f.1c();1Q(j i=0,R;(R=b[i]);i++){4(i>0)e.f.T("<1P/>");e.f.T(R)}e.f.1x()}p{e.m.D(m).l();e.f.q()}4(7(2).1d&&$(2).o())e.o.D($(2).o().1O(\'1N://\',\'\')).l();p e.o.q();e.3.P(7(2).X);4(7(2).H)e.3.H();1f.1L(2,1K)}8 l(){B=S;4((!A||!$.N.L)&&7(9).r){4(e.3.I(":17"))e.3.Q().l().O(7(9).r,9.11);p e.3.I(\':1a\')?e.3.O(7(9).r,9.11):e.3.1G(7(9).r)}p{e.3.l()}u()}8 u(c){4($.k.w)g;4(c&&c.1W.1X=="1E"){g}4(!M&&e.3.I(":1a")){$(K.f).1b(\'W\',u)}4(9==S){$(K.f).1b(\'W\',u);g}e.3.V("z-14").V("z-1A");j b=e.3[0].1z;j a=e.3[0].1y;4(c){b=c.2o+7(9).E;a=c.2n+7(9).G;j d=\'1w\';4(7(9).2k){d=$(C).1r()-b;b=\'1w\'}e.3.n({E:b,14:d,G:a})}j v=z(),h=e.3[0];4(v.x+v.1s<h.1z+h.1n){b-=h.1n+20+7(9).E;e.3.n({E:b+\'1C\'}).P("z-14")}4(v.y+v.1t<h.1y+h.1m){a-=h.1m+20+7(9).G;e.3.n({G:a+\'1C\'}).P("z-1A")}}8 z(){g{x:$(C).2e(),y:$(C).2d(),1s:$(C).1r(),1t:$(C).2p()}}8 q(a){4($.k.w)g;4(B)2c(B);9=S;j b=7(2);8 J(){e.3.V(b.X).q().n("1g","")}4((!A||!$.N.L)&&b.r){4(e.3.I(\':17\'))e.3.Q().O(b.r,0,J);p e.3.Q().2b(b.r,J)}p J();4(7(2).H)e.3.1l()}})(2a);',62,155,'||this|parent|if|||settings|function|current||||||body|return|||var|tooltip|show|title|css|url|else|hide|fade||div|update||blocked|||viewport|IE|tID|window|html|left|each|top|fixPNG|is|complete|document|bgiframe|track|fn|fadeTo|addClass|stop|part|null|append|bodyHandler|removeClass|mousemove|extraClass|backgroundImage|delay|h3|tOpacity|false|tooltipText|right||id|animated|showBody|true|visible|unbind|empty|showURL|save|handle|opacity|defaults|class|data|attr|unfixPNG|offsetHeight|offsetWidth|position|src|createHelper|width|cx|cy|relative|extend|auto|hideWhenEmpty|offsetTop|offsetLeft|bottom|filter|px|none|OPTION|RegExp|fadeIn|navigator|png|match|arguments|apply|test|http|replace|br|for|shift|click|split|mouseout|jquery|target|tagName|nodeType|call||mouseover|alt|bind|removeAttr|200|setTimeout|appendTo|href|MSIE|jQuery|fadeOut|clearTimeout|scrollTop|scrollLeft|absolute|msie|crop|sizingMethod|enabled|positionLeft|AlphaImageLoader|Microsoft|pageY|pageX|height|DXImageTransform|progid|block|userAgent|browser'.split('|'),0,{}));

//	PLUGIN: jquery.mousewheel
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);

//	field values
var fields					= new Object;
fields['auth_txt_1']		= 'E-mail-ul dumneavoastra';
fields['auth_txt_2']		= 'Parola dumneavoastra';
fields['passwd_txt_1']		= 'E-mail-ul dumneavoastra';
fields['nu_txt_1']			= 'Nume';
fields['nu_txt_2']			= 'Prenume';
fields['nu_txt_3']			= 'E-mail';
fields['nu_txt_4']			= 'Parola';
fields['nu_txt_5']			= 'Repetare parola';
fields['nu_txt_6']			= 'Nume firma';
fields['nu_txt_7']			= 'Oras';
fields['nu_txt_8']			= 'Adresa';
fields['nu_txt_9']			= '';
fields['nu_txt_10']			= 'Cod postal';
fields['nu_txt_11']			= 'Telefon';
fields['nu_txt_12']			= 'Cod fiscal';
fields['nu_txt_13']			= 'Numar Registrul Comertului';
fields['nu_txt_14']			= 'Nume banca';
fields['nu_txt_15']			= 'IBAN';
fields['nu_txt_16']			= 'Website URL';
fields['nu_txt_17']			= 'Fax';
fields['client_txt_1']		= 'Numele companiei';
fields['client_txt_2']		= 'Persoana de contact';
fields['client_txt_3']		= 'Adresa de e-mail';
fields['client_txt_4']		= 'Telefon';
fields['client_txt_5']		= 'Fax';
fields['client_txt_6']		= 'Adresa';
fields['client_txt_7']		= 'Cod postal';
fields['client_txt_8']		= 'Oras';
fields['user_mod_txt_1']	= '';
fields['user_mod_txt_2']	= '';
fields['user_mod_txt_3']	= '';
fields['passwd_mod_txt_1']	= '';
fields['passwd_mod_txt_2']	= '';
fields['passwd_mod_txt_3']	= '';
fields['comp_mod_txt_1']	= '';
fields['comp_mod_txt_2']	= '';
fields['comp_mod_txt_3']	= '';
fields['comp_mod_txt_4']	= '';
fields['comp_mod_txt_5']	= '';
fields['comp_mod_txt_6']	= '';
fields['comp_mod_txt_7']	= '';
fields['comp_mod_txt_8']	= '';
fields['comp_mod_txt_9']	= '';
fields['comp_mod_txt_10']	= '';
fields['comp_mod_txt_11']	= '';
fields['comp_mod_txt_12']	= '';
fields['add_wp_mod_txt_1']	= '';
fields['add_wp_mod_txt_2']	= '';
fields['add_wp_mod_txt_3']	= '';
fields['add_wp_mod_txt_4']	= '';
fields['add_wp_mod_txt_5']	= '';
fields['add_wp_mod_txt_6']	= '';

//	enable input fields values
function input_fields_labels() {	
	for(var field in fields) {
		if($("input[name='" + field + "']").parent().attr('title'))
			$("input[name='" + field + "']").parent().tooltip({delay: 0, track: true});
			
		if($("select[name='" + field + "']").parent().attr('title'))
			$("select[name='" + field + "']").parent().tooltip({delay: 0, track: true});
			
		if($("input[name='" + field + "']").val() != fields[field] && $("input[name='" + field + "']").hasClass('passwd')) {
			$("input[name='" + field + "']").val(fields[field]);
		}
		
		$("input[name='" + field + "']").live('focus', function() {
			var this_p		= $(this).parent();
			var this_name	= $(this).attr('name');
			$(this).parent().removeClass('must-validate').attr('title', '').tooltip();
			if($(this).val() == fields[$(this).attr('name')]) {
				$(this).attr('value', '');
				if($(this).hasClass('passwd')) {
					$(this).remove();
					this_p.append('<input type="password" name="' + this_name + '" value="" class="passwd" />');
					this_p.find("input[name='" + this_name + "']").focus();
				}
			}
		});
		$("input[name='" + field + "']").live('blur', function() {
			var this_p		= $(this).parent();
			var this_name	= $(this).attr('name');
			if($(this).val() == '') {
				$(this).attr('value', fields[$(this).attr('name')]);
				if($(this).hasClass('passwd') && $(this).attr('type') == 'password') {
					this_p.append('<input type="text" name="' + this_name + '" value="' + fields[this_name] + '" class="passwd" />');
					$(this).remove();
				}
			}
		});
		$("textarea[name='" + field + "']").live('focus', function() {
			if($(this).val() == fields[$(this).attr('name')])
				$(this).val('');
		});
		$("textarea[name='" + field + "']").live('blur', function() {
			if($(this).val() == '')
				$(this).val(fields[$(this).attr('name')]);
		});
		$("select[name='" + field + "']").live('focus', function() {
			if($(this).val() == fields[$(this).attr('name')])
				$(this).val('');
		});
		$("select[name='" + field + "']").live('blur', function() {
			if($(this).val() == '')
				$(this).val(fields[$(this).attr('name')]);
		});
	}
}

//	enable submit & reset hrefs
function enable_submit_hrefs() {
	$('a.submit_href').click(function() {
		$("form[name='" + $(this).attr('rel') + "'] input").each(function() {
			if(fields[$(this).attr('name')] == $(this).attr('value'))
				$(this).attr('value', '');
		});
		$("form[name='" + $(this).attr('rel') + "']").submit();
		return false;
	});
	
	$('input.submit_btn').click(function() {
		var form_name	= $(this).parents('form').attr('name');
		$("form[name='" + form_name + "'] input").each(function() {
			if(fields[$(this).attr('name')] == $(this).attr('value'))
				$(this).attr('value', '');
		});
	});
	
	$('a.reset_href').click(function() {
		$("form[name='" + $(this).attr('rel') + "'] input").each(function() {
			if(fields[$(this).attr('name')] != $(this).attr('value'))
				$(this).attr('value', fields[$(this).attr('name')]);
				$(this).parent().attr('title', '').removeClass('must-validate').tooltip();
		});
		$("form[name='" + $(this).attr('rel') + "'] .dd_fp").parent().removeClass('must-validate').tooltip();
		return false;
	});
}

var t_min 				= 0;
var t_max 				= 0;
var completat_ok 		= 0;
var price_per_pachet	= 0;

function disable_prices() {
	//	disable prices
	if (!$('.prices .tab_1').hasClass('disabled_tab')) 			$('.prices').find('.tab_1').addClass('disabled_tab');
	if (!$('.prices .tab_orange').hasClass('disabled_tab')) 	$('.prices').find('.tab_orange').addClass('disabled_tab');
	if (!$('.prices .tab_2').hasClass('disabled_tab')) 			$('.prices').find('.tab_2').addClass('disabled_tab');
	if (!$('.prices .btn_buy').hasClass('disabled_btn')) 		$('.prices').find('.btn_buy').addClass('disabled_btn');

	$('#price_1').html('- - - -<span>.- -</span>');
	$('#price_2').html('- - - -<span>.- -</span>');
	$('#price_3').html('- - - -<span>.- -</span>');
	$('#price_4').html('- - - -<span>.- -</span>');
	$('#price_5').html('- - - -<span>.- -</span>');
	
	//	disable client add
	$('.dd_clients').addClass('dd_clients_disabled');
}

var populate_dds = function(target) {
	//	invalid request
	if (!target.val())
		var start_i = parseInt(target.attr('name')[8], 10) + 1;
	else
		var start_i = parseInt(target.attr('name')[8], 10) + 2;
	
	//	disable following dropdowns
	for (i = start_i; i <= 6; i++) {
		var this_select = target.parents('form').find("select[name='cmd_txt_" + i + "']");
		if (i == 5) {
			$('#custom_value').hide();
			$("select[name='cmd_txt_5']").parent().show();
		}
		if (i < 6) {
			this_select.html('<option>Indisponibil</option>').attr('disabled', true);
			sync_select(this_select);
		} else {
			if(!$('#comanda_qty').hasClass('qty_disabled')) $('#comanda_qty').addClass('qty_disabled');
			if(!$('#btn_client_add').hasClass('disabled_btn')) {
				$('#btn_client_add').addClass('disabled_btn');
				$('.client_form').hide();
			}
		}
	}
	
	disable_prices();
	completat_ok = 0;
	
	//	populate the next dropdown
	var next_dd			= target.parents('form').find("select[name='cmd_txt_" + (parseInt(target.attr('name')[8], 10) + 1) + "']");
	
	//	cmd_txt_1, populam 2
	if (target.attr('name') == 'cmd_txt_1') {
		var dd_data		= window['prod_' + target.val()];
		var html		= '<option value="">Alege</option>';
		for (var value in dd_data)
			html		+= '<option value="' + value + '">' + dd_data[value] + '</option>';
		next_dd.html(html).attr('disabled', false);
		sync_select(next_dd);
	}
	
	//	cmd_txt_2, populam 3
	if (target.attr('name') == 'cmd_txt_2' && target.val()) {
		var tip_lic		= ['Licenta noua', 'Reinnoire licenta', 'Institutii publice', 'Institutii publice reinnoire', 'Migrare'];
		var tip_lic_prod= [];
		var price_type	= price_types[target.val()];
		
		var ind			= 0;
		for (var i = 0; i <= 4; i++) {
			var found_data	= false;
			for (var j = 0; j < window ['prices_' + i][target.val()].length; j++)
				if (window ['prices_' + i][target.val()][j]) {
					found_data	= true;
					break;
				}
				
			if (found_data)
				tip_lic_prod [ind]	= tip_lic [i];
				
			ind++;
		}
		
		//	dd_data
		dd_data			= tip_lic_prod;
		
		//	exceptions for KKS and KPM
		if (target.val() == 72 || target.val() == 73)
			dd_data		= ['Licenta noua'];
		
		var html		= '<option value="">Alege</option>';
		
		for (var value in dd_data)
			html		+= '<option value="' + value + '">' + dd_data[value] + '</option>';
		next_dd.html(html).attr('disabled', false);
		sync_select(next_dd);
	}
	
	// cmd_txt_3, populam 4
	if (target.attr('name') == 'cmd_txt_3' && target.val()) {
		var produs 		= $("select[name='cmd_txt_2']").val();
		var t_years		= years[produs];			
		
		var html		= '<option value="">Alege</option>';
		for (i = 1; i <= t_years; i++)
			html		+= '<option value="' + (i - 1) + '">' + i + ' ' + ((i == 1) ? 'an' : 'ani') + '</option>';
			
		//	exceptions for KKS and KPM
		if (produs == 72 || produs == 73) {
			html		= '<option value="">Alege</option><option value="0">Permanent</option>';
		}
		
		next_dd.html(html).attr('disabled', false);
		sync_select(next_dd);
	}
	
	// cmd_txt_4, populam 5
	if (target.attr('name') == 'cmd_txt_4' && target.val()) {
		t_min			= t_max 	= 0;
		var produs 		= $("select[name='cmd_txt_2']").val();
		var t_ranges 	= ranges[produs];
		var t_users 	= users[produs];
		var price_type	= price_types[produs];
		
		if (price_type == 'fixed') {
			var html 	= '<option value="">Alege</option>';
			var cnt		= 0;
			for (var value in t_ranges) {
				var val = t_ranges[value].split('-');
				html 	+= '<option value="' + cnt + '">' + val[0] + ' ' + t_users[value] + '</option>';
				cnt++;
			}
			next_dd.html(html).attr('disabled', false);
			sync_select(next_dd);
		} else {
			for (var value in t_ranges) {
				var val = t_ranges[value].split('-');
				if (parseInt (val[0], 10) < t_min || t_min == 0) t_min = parseInt (val[0], 10);
				if (parseInt (val[1], 10) > t_max || t_max == 0) t_max = parseInt (val[1], 10);
			}
			html 		= '<label for="custom-statii">' + t_min + '-' + t_max + 'max</label> <input type="text" name="statii_custom" id="statii_custom" onkeyup="apply_custom_statii();" />';
			next_dd.parent().hide();
			$('#custom_value').html(html).show();
		}
	}
	
	// cmd_txt_5, afisam 6
	if (target.attr('name') == 'cmd_txt_5' && target.val()) {
		$('#comanda_qty').removeClass('qty_disabled');
		$('#btn_client_add').removeClass('disabled_btn');
		$('.dd_clients').removeClass('dd_clients_disabled');
		calculate_price();
	}
}

function calculate_price() {
	// reset qty
	$("input[name='cmd_txt_6']").val(1);
	$('#comanda_qty').find('span').html(1);
	var produs 		= parseInt($("select[name='cmd_txt_2']").val(), 10);
	var price_type	= price_types[produs];
	var t_years 	= years[produs];
	var t_year 		= parseInt($("select[name='cmd_txt_4']").val(), 10);
	var lic_nr 		= $("select[name='cmd_txt_3']").val();
	if (price_type == 'fixed')
		var nr_items = parseInt($("select[name='cmd_txt_5']").val(), 10);
	else
		var nr_items = parseInt($('#statii_custom').val(), 10);
	var t_ranges 	= ranges[produs];
	var t_prices 	= window['prices_' + lic_nr];
	
	var range_found = -1;
	for (var value in t_ranges) {
		var val 	= t_ranges[value].split('-');
		val[0] 		= parseInt (val[0], 10);
		val[1] 		= parseInt (val[1], 10);
		if (nr_items >= val[0] && nr_items <= val[1] && range_found == -1)
			range_found = value;
	}
	
	if (price_type == 'fixed') {
		price_per_pachet 		= t_prices[produs][nr_items * t_years + t_year] * $.usd_val;
		completat_ok			= 1;
		populate_prices();
	} else {
		if (range_found != -1) {
			price_per_pachet 		= t_prices[produs][range_found * t_years + t_year] * nr_items * $.usd_val;
			completat_ok			= 1;
			populate_prices();
		}
	}
}

function populate_prices() {
	var produs 		= parseInt($("select[name='cmd_txt_2']").val(), 10);
	var license		= parseInt($("select[name='cmd_txt_3']").val(), 10);
	var years 		= parseInt($("select[name='cmd_txt_4']").val(), 10);
	var users 		= parseInt($("select[name='cmd_txt_5']").val(), 10);
	
	/*
	//	PROMO KSOS
	if (produs == 69 && license == 0 && years == 0 && users == 0)
		price_per_pachet	= 399.99;
	if (produs == 69 && license == 0 && years == 0 && users == 1)
		price_per_pachet	= 499.99;
	//	END PROMO KSOS
	*/
	
	//	PROMO KIS/KAV
	/*
	if ((produs == 74 || produs == 75) && years == 0 && license == 0 && users < 2)
		price_per_pachet	*= 4/5;
	*/
	//	END PROMO KIS/KAV
	
	/*
	//	PROMO 2011 XMAS
	if (license == 0) {
		if (produs == 74 && users == 0)
			price_per_pachet	= 168 / 1.24;
		if (produs == 74 && users == 1)
			price_per_pachet	= 198 / 1.24;
		if (produs == 74 && users == 2)
			price_per_pachet	= 298 / 1.24;
		if (produs == 75 && users == 0)
			price_per_pachet	= 118 / 1.24;
		if (produs == 75 && users == 1)
			price_per_pachet	= 158 / 1.24;
		if (produs == 75 && users == 2)
			price_per_pachet	= 248 / 1.24;
	}
	//	END PROMO 2011 XMAS
	*/
	
	var p_nr 		= parseInt ($("input[name='cmd_txt_6']").val(), 10);
	var total_price = p_nr * price_per_pachet;
	
	//	buying price
	var price_4		= price_per_pachet - $.discount * price_per_pachet / 100;
	var price_str 	= price_4.toFixed(2).toString().split('.');
	var price_4_int	= price_str[0];
	var price_4_dec	= price_str[1];
	
	//	price incentive (3 din pretul fara TVA)
	var price_1		= 0.03 * price_4 * p_nr;
	var price_str 	= price_1.toFixed(2).toString().split('.');
	var price_1_int	= price_str[0];
	var price_1_dec	= price_str[1];
	
	//	partner's revenue (_discount_% din pretul fara TVA)
	var price_2		= $.discount * total_price / 100;
	var price_str 	= price_2.toFixed(2).toString().split('.');
	var price_2_int	= price_str[0];
	var price_2_dec	= price_str[1];
	
	//	sale price
	var price_str 	= total_price.toFixed(2).toString().split('.');
	var price_3_int	= price_str[0];
	var price_3_dec	= price_str[1];	
	
	//	buying price * qty
	var price_5		= price_4 * p_nr;
	var price_str 	= price_5.toFixed(2).toString().split('.');
	var price_5_int	= price_str[0];
	var price_5_dec	= price_str[1];
	
	// 	enable fields
	$('.prices').find('.tab_1').removeClass('disabled_tab');
	$('.prices').find('.tab_orange').removeClass('disabled_tab');
	$('.prices').find('.tab_2').removeClass('disabled_tab');
	if (completat_ok && (parseInt($('#client_id').val(), 10 ) != 0 || $('.client_form').is(':visible')))
		$('.prices').find('.btn_buy').removeClass('disabled_tab');
	
	$('#price_1').html( price_1_int + '<span>.' + price_1_dec + '</span>' );
	$('#price_2').html( price_2_int + '<span>.' + price_2_dec + '</span>' );
	$('#price_3').html( price_3_int + '<span>.' + price_3_dec + '</span>' );
	$('#price_4').html( price_4_int + '<span>.' + price_4_dec + '</span>' );
	$('#price_5').html( price_5_int + '<span>.' + price_5_dec + '</span>' );
}

function apply_custom_statii() {
	var val = parseInt( $('#statii_custom').val(), 10 );	
	if( val >= t_min && val <= t_max ) {
		$('#comanda_qty').removeClass('qty_disabled');
		$('#btn_client_add').removeClass('disabled_btn');
		$('.custom-statii').removeClass('custom-statii-notok');
		$('.dd_clients').removeClass('dd_clients_disabled');
		
		completat_ok = 1;
		calculate_price();
	} else {
		$('.custom-statii').addClass('custom-statii-notok');
		$('.dd_clients').addClass('dd_clients_disabled');
		completat_ok = 0;
		if(!$('#comanda_qty').hasClass('qty_disabled')) $('#comanda_qty').addClass('qty_disabled');
		if(!$('#btn_client_add').hasClass('disabled_btn')) {
			$('#btn_client_add').addClass('disabled_btn');
			$('.client_form').hide();
		}
		disable_prices();
	}
}

var custom_selects_hide = function(oTarget){
	var ulVisible = $('.custom_form .ul_wrapper:visible');
	ulVisible.each(function(){
		var oSelect = $(this).parents("div:eq(0)").find("select").get(0);
		if( !(oTarget && oSelect.oLabel && oSelect.oLabel.get(0) == oTarget.get(0)) ){$(this).hide();}
	});
};

var bgClick = function(event) {
	if ($(event.target).parents('.custom_form').length === 0) { 
		custom_selects_hide($(event.target));
	}
	
	if (!$(event.target).is('.dd_special') && !$(event.target).is('.dd_special *')) {
		$('.dd_special').hide();
	}
};

function sync_select(target) {
	var wrapper	= target.parent();
	var ul		= $('ul', wrapper);
	var ulw		= $('div.ul_wrapper', wrapper);
	ul.find('li').remove();
	
	var li_cnt	= 0;
	$('option', target).each(function(){
		var oLi = $('<li><a href="#" rel="'+ $(this).attr('value') +'">'+ $(this).html() +'</a></li>');
		ul.append(oLi);
		li_cnt++;
	});
	
	if (li_cnt == 1 && target.attr('name') != 'emp_id' && !wrapper.hasClass('dd_263'))
		target.attr('disabled', true);
	
	if(target.attr('disabled'))
		wrapper.addClass('dd_disabled');
	else
		wrapper.removeClass('dd_disabled');
	
	/* Add click handler to the a */
	ul.find('a').click(function() {
		$('a.selected', wrapper).removeClass('selected');
		$(this).addClass('selected');	
		/* Fire the onchange event */
		if (target.val() != $(this).attr('rel')) {
			target.val($(this).attr('rel'));
			target.change();
		}
		target.val($(this).attr('rel'));
		$('span:eq(0)', wrapper).html($(this).html());
		$('div.ul_wrapper', wrapper).hide();
		return false;
	});
	
	/* Set the default */
	$('a:eq('+ target.get(0).selectedIndex +')', ul).click();
		
	ul.show();
	ulw.css({display:'block',visibility:'hidden'});
	var iSelectHeight = ($('li',ul).length) * ($('li:first',ul).height()) + 2;
	//(iSelectHeight < ul.height()) && ul.css({height:iSelectHeight,'overflow':'hidden'});
	ul.css({height:iSelectHeight,'overflow':'hidden'});
	if (iSelectHeight > 200)
		ul.css({height:200,'overflow':'auto'});
	ulw.css({display:'none',visibility:'visible'});
}

function wp_change (target) {
	if (target.val() != 0)
		target.parents('form').find('a.btn_small').show();
	else
		target.parents('form').find('a.btn_small').hide();
}

function wp_click() {
	$('#user .mod_small_2 select.dd_263').parents('form').find('a.btn_small').click(function() {
		if (confirm ('Confirmati stergerea punctului de lucru "' + $('#user .mod_small_2 select.dd_263 option:selected').html() + '".'))
			window.location = $.base_url + 'user/del_wp/' + $('#user .mod_small_2 select.dd_263').val();
		
		return false;
	});
}

function user_del_click() {
	$('#user .left select.dd_263').parents('form').find('a.btn_small').click(function() {
		if ($('#user .left select.dd_263 option:selected').attr('rel') == 'false') {
			if (confirm ('Confirmati stergerea utilizatorului "' + $('#user .left select.dd_263 option:selected').html() + '".'))
				window.location = $.base_url + 'user/del_user/' + $('#user .left select.dd_263').val();
		} else {
			alert ('Utilizatorul "' + $('#user .left select.dd_263 option:selected').html() + '" nu poate fi sters deoarece are fonduri Incentive asociate contului sau!');
		}
		
		return false;
	});
}

function custom_selects() {
	$(document).mousedown(bgClick);
	
	//	bind change event for each select
	$('form.place_order select:not(.dd_special):not(.dd_emp):not(.dd_263)').change(function() { populate_dds($(this)); });
	$('#user .mod_small_2 select.dd_263').change(function() { wp_change($(this)); });
	$('#user .left select.dd_263').change(function() { wp_change($(this)); });
	
	//	transform each select
	$('form.custom_form select:not(.dd_special)').each(function() {
		var $select			= $(this);
		var wrapper_class	= '';
		var ul_width		= 0;
		
		if($(this).hasClass('dd_95')) {
			wrapper_class 	= 'dd_95';
			ul_width		= 95;
		}
			
		if($(this).hasClass('dd_175')) {
			wrapper_class 	= 'dd_175';
			ul_width		= 175;
		}
			
		if($(this).hasClass('dd_235')) {
			wrapper_class 	= 'dd_235';
			ul_width		= 235;
		}
		
		if($(this).hasClass('dd_263')) {
			wrapper_class 	= 'dd_263';
			ul_width		= 261;
		}
			
		if($(this).hasClass('dd_emp')) {
			wrapper_class 	= 'dd_emp';
			ul_width		= 234;
		}
		
		if($(this).hasClass('dd_fp')) {
			wrapper_class 	= 'dd_fp';
			ul_width		= 200;
		}
		
		var $wrapper = $select
					.wrap('<div class="' + wrapper_class + '"></div>')
					.hide()
					.parent()
					.css({zIndex: 10});
		
		$wrapper.prepend('<div><span></span></div><div class="ul_wrapper"><em class="up"></em><ul></ul><em class="down"></em></div>');
		var $ul 	= $('ul', $wrapper).css('width', ul_width).hide();
		var $ulw	= $('div.ul_wrapper', $wrapper).hide();
		
		sync_select($select);
		
		$wrapper.click(function() {
			$wrapper.parent().removeClass('must-validate').attr('title', '').tooltip();
			if($ulw.css('display') == 'none') {custom_selects_hide();} 
			if($select.attr('disabled')){return false;}
			$ulw.slideToggle('fast', function(){});
		});
				
	});
}

function special_select() {
	$sel			= $("select[name='dd_special']");
	
	//	build the wrapper
	var $wrapper	= 	$sel
						.hide()
						.parent()
						.append('<div class="dd_special"><div class="scroll_left_side"><div class="scroll_left"><span>PERSOANE FIZICE</span><div class="scroll_btns"><a href="#" title="" class="up"></a><a href="#" title="" class="down"></a></div></div><div class="content_left"><ul></ul></div></div> <div class="scroll_right_side"><div class="scroll_right"><span>PERSOANE JURIDICE</span><div class="scroll_btns"><a href="#" title="" class="up"></a><a href="#" title="" class="down"></a></div></div><div class="content_right"><ul></ul></div></div></div>');
	$('div.dd_special').hide();
	
	$('optgroup:eq(0) option', $sel).each(function(index) {
		if ($(this).attr('value') != '-')
			$('div.dd_special .content_left ul').append('<li><a href="#" rel="' + $(this).attr('value') + '" label="' + $(this).attr('label') + '">' + $(this).html() + '</a></li>');
		else
			$('div.dd_special .content_left ul').append('<li>' + $(this).html() + '</li>');
	});
	
	$('optgroup:eq(1) option', $sel).each(function(index) {
		if ($(this).attr('value') != '-')
			$('div.dd_special .content_right ul').append('<li><a href="#" rel="' + $(this).attr('value') + '" label="' + $(this).attr('label') + '">' + $(this).html() + '</a></li>');
		else
			$('div.dd_special .content_right ul').append('<li>' + $(this).html() + '</li>');
	});
	
	function lists_width(expanded, contracted) {
		expanded.clearQueue().animate({width: 265}, 200, 'linear', function() {
			$('.scroll_btns a', expanded.parent()).removeClass('disabled');
			$('span', expanded.parent()).removeClass('disabled');
			expanded.find('ul').removeClass('disabled');
		});
		contracted.clearQueue().animate({width: 0}, 200, 'linear', function() {
			$('.scroll_btns a', contracted.parent()).addClass('disabled');
			$('span', contracted.parent()).addClass('disabled');
			contracted.find('ul').addClass('disabled');
		});
	}
	$('.dd_special ul').css('top', '10px');
	$('.scroll_left_side', $wrapper).mouseenter(function() { lists_width($('.content_left', $wrapper), $('.content_right', $wrapper)); });
	$('.scroll_right_side', $wrapper).mouseenter(function() { lists_width($('.content_right', $wrapper), $('.content_left', $wrapper)); });

	$('.scroll_btns a.up').click(function() {
		$ul = $('ul', $(this).parent().parent().parent());
		
		var act_top = parseInt($ul.css('top'), 10) + 23;
		if (parseInt($ul.css('top'), 10) < 0) {
			$ul.stop(true, true).animate({top: act_top + 'px'}, 100, function() {
				$ul.css('top', act_top + 'px');
			});
		}
		return false;
	});
	$('.scroll_btns a.down').click(function() {
		$ul = $('ul', $(this).parent().parent().parent());
		
		if (($ul.find('li').length - 6) * -23 < parseInt ($ul.css('top'), 10) - 14) {
			var act_top = parseInt($ul.css('top'), 10) - 23;
			$ul.stop(true, true).animate({top: act_top + 'px'}, 100, function() {
				$ul.css('top', act_top + 'px');
			});
		}
		return false;
	});
	
	$('div.dd_special li a').click(function() {
		$('span.client_selected').html($(this).html());
		$("select[name='dd_special']").val($(this).attr('rel'));
		
		var crt_clients	= clients[$(this).attr('label')].split("[]");
		for (var i = 0; i < crt_clients.length; i++)
			if (crt_clients[i] && crt_clients[i] != '-')
				$("input[name='client_txt_" + (i + 1) + "']").val(crt_clients[i]);
			else
				$("input[name='client_txt_" + (i + 1) + "']").val(fields['client_txt_' + (i + 1)]);
		
		$('.btn_buy').removeClass('disabled_btn');
		
		$('.dd_clients').find('.dd_special').slideUp();
		$('.client_form').slideUp();
		$('.dd_clients .btn_edit').show();
		
		return false;
	});
	
	//	client edit button
	$('.dd_clients .btn_edit').click(function() {
		if($('.dd_special').is(':visible')) 
			$('.dd_special').slideUp();
			
		$('.client_form').slideDown();
		return false;
	});
	
	//	click event
	$('.dd_clients').click(function(e) {
		if(clients_open_click(e)) {
			if(!$(this).find('div.dd_special').is(':visible')) {
				$(this).find('div.dd_special').slideDown();
			} else {
				$(this).find('div.dd_special').slideUp();
			}
		}
	});	
}

function header_tooltip() {
	$('#header .misc h2').mouseenter(function() {
		$('#header .misc .tooltip').clearQueue();
		$('#header .misc .tooltip').show().animate({opacity: 0}, 1).animate({opacity: 1, paddingTop: '30px'}, 200);
		$('#header .misc h2 i').addClass('hovered');
	});
	$('#header .misc .tooltip').mouseleave(function() {
		$(this).clearQueue();
		$(this).animate({opacity: 0, paddingTop: '50px'}, 250, function() {$(this).hide();});
		$('#header .misc h2 i').removeClass('hovered');
	});
	$('#place_order .client_add .incentive_program').mouseenter(function() {
		$('#place_order .tooltip_incentive').clearQueue();
		$('#place_order .tooltip_incentive').css('padding-top', '73px');
		$('#place_order .tooltip_incentive').show().animate({opacity: 0}, 1).animate({opacity: 1, paddingTop: '43px'}, 200);
	});
	$('#place_order .client_add .incentive_program').mouseleave(function() {
		$('#place_order .tooltip_incentive').animate({opacity: 0, paddingTop: '73px'}, 250, function() {$(this).hide();});
	});
}

function menu_dropdowns() {
	$('#header ul.menu > li ul li:last-child span').remove();
	$('#header ul.menu > li').each(function() {
		var cat_title	= $(this).find('a:first').html();
		var ul_count	= 0;
		var ul_content	= $(this).find('ul').html();
		
		if (ul_content == '')
			return;
			
		$(this).mouseenter(function() {
			if(ul_content) {
				$(this).append('<div class="dd_tab"><span class="left"></span><span class="mid">' + cat_title + '</span><span class="right"></span></div>');
				$(this).append('<div class="dd_menu"><div class="left"></div><ul>' + ul_content + '</ul><div class="right"></div></div>');
				var left_val	= $(this).offset().left - 20;
				if (left_val + $(this).find('.dd_menu').width() > 990) {
					left_val	= 990 - $(this).find('.dd_menu').width();
				}
				$(this).find('.dd_menu').css('left', left_val);
				$(this).find('.dd_tab, .dd_menu').show();
			}
		});
	});
	
	$('#header ul.menu li').mouseleave(function() {
		$(this).find('div').remove();
	});
}

function clients_open_click(e) {
	if(($(e.target).is('.dd_clients') || $(e.target).is('.client_selected')) && !$('.dd_clients').hasClass('dd_clients_disabled'))
		return true;
	return false;
}

function order_qty() {
	//	order qty up
	$('#comanda_qty a.up').click(function() {
		var qty_nr = parseInt( $("input[name='cmd_txt_6']").val(), 10 );
		if($('#comanda_qty').hasClass('qty_disabled'))
			return false;
		
		qty_nr++;
		$("input[name='cmd_txt_6']").val(qty_nr);
		$("#comanda_qty").find('span').html(qty_nr);
		populate_prices();
		
		return false;
	});
	
	//	order qty down
	$('#comanda_qty a.down').click(function() {
		var qty_nr = parseInt( $("input[name='cmd_txt_6']").val(), 10 );
		if($('#comanda_qty').hasClass('qty_disabled'))
			return false;
		
		qty_nr--;
		if( qty_nr > 0 ) {
			$("input[name='cmd_txt_6']").val(qty_nr);
			$("#comanda_qty").find('span').html(qty_nr);
			populate_prices();
		}
		
		return false;
	});
}

function add_client() {
	//	add client button
	$('#btn_client_add').click(function() {
		if ($('#btn_client_add').hasClass('disabled_btn'))
			return false;
		
		$('.btn_buy').removeClass('disabled_btn');
		
		for (var i = 1; i <= 8; i++)
			$("input[name='client_txt_" + i + "']").val(fields['client_txt_' + i]);
		$('.client_selected').html('Selectati din lista clientul existent');
		
		if (!$('.client_form').is(':visible'))	
			$('.client_form').slideDown();
		$("select[name='dd_special']").val(0);
		
		if(completat_ok && $('.btn_buy').hasClass('disabled_btn')) 
			$('.btn_buy').removeClass('disabled_tab');
		$('.dd_clients .btn_edit').hide();
		
		return false;
	});
}

function add_to_cart() {
	//	add to cart button (buy)
	$('div.prices a.btn_buy').click(function() {		
		//	quit if disabled
		if ($(this).hasClass('disabled_btn'))
			return false;
		
		//	send data...
		var cmd_txt_2 		= parseInt($("select[name='cmd_txt_2']").val(), 10);
		var cmd_txt_3 		= parseInt($("select[name='cmd_txt_3']").val(), 10);
		var cmd_txt_4 		= parseInt($("select[name='cmd_txt_4']").val(), 10);
		if (price_types[cmd_txt_2] == 'fixed')
			var cmd_txt_5 	= parseInt($("select[name='cmd_txt_5']").val(), 10);
		else 
			var cmd_txt_5 	= parseInt($('#statii_custom').val(), 10);
		var cmd_txt_6 		= parseInt($("input[name='cmd_txt_6']").val(), 10);
		var emp_id 			= parseInt($("select[name='emp_id']").val(), 10);
		
		//	client data
		var client_data		= new Array();
		for (var i = 1; i <= 8; i++) {
			client_data[i - 1]	= fields["client_txt_" + i] == $("input[name='client_txt_" + i + "']").val() ? '' : $("input[name='client_txt_" + i + "']").val();
		}
		
		var dd_special		= $("select[name='dd_special']").val();
		if (dd_special == null)
			dd_special		= '-';
		
		$.ajax({
			url: $.base_url + 'comenzi/add',
			data: {
				cmd_txt_2 		: cmd_txt_2,
				cmd_txt_3 		: cmd_txt_3,
				cmd_txt_4 		: cmd_txt_4,
				cmd_txt_5 		: cmd_txt_5,
				cmd_txt_6 		: cmd_txt_6,
				client_txt_1	: client_data[0],
				client_txt_2	: client_data[1],
				client_txt_3	: client_data[2],
				client_txt_4	: client_data[3],
				client_txt_5	: client_data[4],
				client_txt_6	: client_data[5],
				client_txt_7	: client_data[6],
				client_txt_8	: client_data[7],
				emp_id			: emp_id,
				client_id		: dd_special
			},
			dataType: 'json',
			type: 'POST',
			success: function(data, text, request) {
				var php_validated	= true;
				$('.client_form .input_273').removeClass('must-validate').attr('title', '').tooltip();
				if (data.client_txt_1.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_1']").parent().addClass('must-validate').attr('title', data.client_txt_1.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_2.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_2']").parent().addClass('must-validate').attr('title', data.client_txt_2.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_3.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_3']").parent().addClass('must-validate').attr('title', data.client_txt_3.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_4.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_4']").parent().addClass('must-validate').attr('title', data.client_txt_4.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_5.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_5']").parent().addClass('must-validate').attr('title', data.client_txt_5.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_6.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_6']").parent().addClass('must-validate').attr('title', data.client_txt_6.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_7.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_7']").parent().addClass('must-validate').attr('title', data.client_txt_7.validation).tooltip({delay: 0, track: true});
				}
				if (data.client_txt_8.validation != '') {
					php_validated	= false;
					$("input[name='client_txt_8']").parent().addClass('must-validate').attr('title', data.client_txt_8.validation).tooltip({delay: 0, track: true});
				}
				
				if (!php_validated) {
					$('.client_form').show();
					return false;
				}
				
				//	success, product added to cart
				window.location	= $.base_url + 'comenzi/place';
			}
		});
		
		return false;
	});
}

function home_scroll_box() {
	var animating	= false;
	var cmd_size	= $('#comenzi .scroll_box .order').size();
	
	if (cmd_size < 4) {
		$('#comenzi .scroll_btns a').hide();
	}	
	
	$('#comenzi .scroll_btns a.up').click(function() {
		var offset	= $('#comenzi .scroll_box .order:eq(0)').offset().top - $('#comenzi .scroll_box').offset().top;
		
		if ($('#comenzi .scroll_box .order:eq(0)').offset().top < $('#comenzi .scroll_box').offset().top && !animating) {
			var margin_top	= offset + 81;
			animating		= true;
			$('#comenzi .scroll_box .order:eq(0)').animate({'margin-top' : margin_top + 'px'}, 200, 'swing', function() {animating = false;});
		}

		return false;
	});
	
	$('#comenzi .scroll_btns a.down').click(function() {
		var offset		= $('#comenzi .scroll_box .order:eq(0)').offset().top - $('#comenzi .scroll_box').offset().top;
		var offset_min	= $('#comenzi .scroll_box').offset().top - ($('#comenzi .scroll_box .order').size() - 4) * 81;
		
		if ($('#comenzi .scroll_box .order:eq(0)').offset().top > offset_min && !animating) {
			var margin_top	= offset - 81;
			animating		= true;
			$('#comenzi .scroll_box .order:eq(0)').animate({'margin-top' : margin_top + 'px'}, 200, 'swing', function() {animating = false;});
		}

		return false;
	});
	
	$('#comenzi .scroll_box').mousewheel(function(event, delta) {
		if (delta > 0)
			$('#comenzi .scroll_btns a.up').click();
		else
			$('#comenzi .scroll_btns a.down').click();
		return false;
	});
}

function home_get_news() {
	var crt_page = -5;
	
	$('#news .module_nav_bottom a.prev').click(function() {		
		if (crt_page > 0) {
			crt_page	-= 5;
			$(this).parent().find('a.next').removeClass('disabled');
			if (crt_page == 0)
				$(this).addClass('disabled');
		} else
			return false;
			
		//	show loading animation
		var span_loading	= $(this).parent().find('span.loading');
		span_loading.css({'display' : 'block'});
		
		//	send request
		$.ajax({
			url			: $.base_url + 'misc/get_news',
			data		: {crt_page : crt_page},
			dataType	: 'json',
			type		: 'POST',
			success		: function(data, text, request) {
				$('#news ul.noutati li').remove();
				$('#news ul.noutati').append(data.content);
				//	hide loading animation
				span_loading.css({'display' : 'none'});
			}
		});
		
		return false;
	});
	
	$('#news .module_nav_bottom a.next').click(function() {
		if (crt_page < 10) {
			if (crt_page != -5)
				$(this).parent().find('a.prev').removeClass('disabled');
			crt_page	+= 5;
			if (crt_page == 10)
				$(this).addClass('disabled');
		} else
			return false;
			
		//	show loading animation
		var span_loading	= $(this).parent().find('span.loading');
		span_loading.css({'display' : 'block'});
			
		$.ajax({
			url			: $.base_url + 'misc/get_news',
			data		: {crt_page : crt_page},
			dataType	: 'json',
			type		: 'POST',
			success		: function(data, text, request) {
				$('#news ul.noutati li').remove();
				$('#news ul.noutati').append(data.content);
				//	hide loading animation
				span_loading.css({'display' : 'none'});
			}
		});
		
		return false;
	});
	$('#news .module_nav_bottom a.next').click();
}

function home_get_awd() {
	var crt_page = -2;
	
	$('#awd .module_nav_bottom a.prev').click(function() {		
		if (crt_page > 0) {
			crt_page	-= 2;
			$(this).parent().find('a.next').removeClass('disabled');
			if (crt_page == 0)
				$(this).addClass('disabled');
		} else
			return false;
			
		//	show loading animation
		var span_loading	= $(this).parent().find('span.loading');
		span_loading.css({'display' : 'block'});
		
		//	send request
		$.ajax({
			url			: $.base_url + 'misc/get_awd',
			data		: {crt_page : crt_page},
			dataType	: 'json',
			type		: 'POST',
			success		: function(data, text, request) {
				$('#awd ul.awards li').remove();
				$('#awd ul.awards').append(data.content);
				//	hide loading animation
				span_loading.css({'display' : 'none'});
			}
		});
		
		return false;
	});
	
	$('#awd .module_nav_bottom a.next').click(function() {
		if (crt_page < 6) {
			if (crt_page != -2)
				$(this).parent().find('a.prev').removeClass('disabled');
			crt_page	+= 2;
			if (crt_page == 6)
				$(this).addClass('disabled');
		} else
			return false;
			
		//	show loading animation
		var span_loading	= $(this).parent().find('span.loading');
		span_loading.css({'display' : 'block'});
			
		$.ajax({
			url			: $.base_url + 'misc/get_awd',
			data		: {crt_page : crt_page},
			dataType	: 'json',
			type		: 'POST',
			success		: function(data, text, request) {
				$('#awd ul.awards li').remove();
				$('#awd ul.awards').append(data.content);
				//	hide loading animation
				span_loading.css({'display' : 'none'});
			}
		});
		
		return false;
	});
	$('#awd .module_nav_bottom a.next').click();
}

//	replace numbers with images
function replace_numbers() {
	$('.date h3').each(function() {
		var numbers 	= $(this).text().split("");
		var images		= '';
		for(i = 0; i < numbers.length; i++) {
			images 		+= '<img src="' + $.base_url + 'part_img/layout/letter_' + numbers[i] + '.png" alt="' + numbers[i] + '" />';
		}
		$(this).html(images);
	});
}

//	disable home buttons
function home_btns() {
	if ($('#report_btn em:last').text() == 'Update: -') {
		$('#report_btn').click (function () {
			alert ('Nu aveti nicio comanda finalizata.');
			return false;
		});
	}
	
	if ($('#zip_invoices_btn i:last').text() == 'Niciun fisier') {
		$('#zip_invoices_btn').click (function () {
			alert ('Nu aveti nicio comanda efectuata.');
			return false;
		});
	}
}

//	parteneriat buttons
function parteneriat_btns() {
	$('#parteneriat .btn').click(function() {
		var p_type	= '';
		var btn		= $(this);
		
		if (btn.hasClass('disabled'))
			return false;
		
		if ($(this).hasClass('gold'))
			p_type	= 'gold';
		if ($(this).hasClass('platinium'))
			p_type	= 'platinium';
		
		//	send request
		btn.addClass('disabled');
		$.ajax({
			url			: $.base_url + 'misc/parteneriat_req',
			data		: {req_type : p_type},
			dataType	: 'json',
			type		: 'POST',
			success		: function(data, text, request) {
				alert (data.message);
			}
		});
		
		return false;
	});
}

//	suport upload
function suport_upload() {
	$('#suport .input_upload').each(function(ind) {
		var file	= $(this).find('input[type=file]');
		var desc	= $(this).find('.filename');
		
		if (file.val())
			desc.html(file.val());
	});
	
	$('input[type=file]').change(function(e) {
		$(this).parent().parent().find('.filename').html($(this).val());
	});
}

$(document).ready(function() {
	input_fields_labels();
	enable_submit_hrefs();
	custom_selects();
	special_select();
	header_tooltip();
	menu_dropdowns();
	order_qty();
	add_client();
	add_to_cart();
	home_scroll_box();
	wp_click();
	user_del_click();
	replace_numbers();
	home_btns();
	parteneriat_btns();
	suport_upload();
});
