 /* выбор города */
var request_city = false;
   try {
     request_city = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       request_city = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request_city = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request_city = false;
       }
     }
   }

   if (!request_city)
     alert("Error initializing XMLHttpRequest!");
     
function update_list_cities() 
{
  var select = document.getElementById("country");
  var id = select.value;
  if (id)
  {
  var url = "/inc/ajax_cities.php?seed=" + Math.round(100*Math.random()) + "&id=" + id;

  request_city.open("GET", url, true);
  request_city.onreadystatechange = update_list;
  request_city.send(null);
  }
}

function update_list_cities2() 
{
  var select = document.getElementById("country2");
  var id = select.value;
  if (id)
  {
  var url = "/inc/ajax_cities.php?seed=" + Math.round(100*Math.random()) + "&id=" + id;

  request_city.open("GET", url, true);
  request_city.onreadystatechange = update_list2;
  request_city.send(null);
  }
}

function update_list() {
     if (request_city.readyState == 4) {
       if (request_city.status == 200) {
       var select = document.getElementById("city");
       select.options.length = 0;
       var data = request_city.responseText;
       var arr = data.split('|');
       
       for(var i in arr){
        // в массиве val - поля полученной таблицы
        val = arr[i].split('@');
        // добавляем новый объект OPTION к нашему SELECT
        select.options[select.options.length]=
        new Option(val[1], val[0], false, false);
    }
       
       } else
         alert("status is " + request_city.status);
     }
   }
   
 function update_list2() {
     if (request_city.readyState == 4) {
       if (request_city.status == 200) {
       var select = document.getElementById("city2");
       select.options.length = 0;
       var data = request_city.responseText;
       var arr = data.split('|');
       
       for(var i in arr){
        // в массиве val - поля полученной таблицы
        val = arr[i].split('@');
        // добавляем новый объект OPTION к нашему SELECT
        select.options[select.options.length]=
        new Option(val[1], val[0], false, false);
    }
       
       } else
         alert("status is " + request_city.status);
     }
   }
/* выбор города */ 
 
/* личные сообщения */
var request = false;
   try {
     request = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request = false;
       }
     }
   }

   if (!request)
     alert("Error initializing XMLHttpRequest!");
     
function get_new_message(id)
{
	var url = "/get_new_message/" + id + ".html";

	request.open("GET", url, true);
    request.onreadystatechange = updatePage;
    request.send(null);
	
	setTimeout("get_new_message(" + id + ")", 30000);

}

function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {

if (request.responseText.length>0)
	{
	var arr = request.responseText.split("|");
	if (document.getElementById('new_msg') && !isNaN(arr[0])) document.getElementById('new_msg').innerHTML = " " + arr[0];
	}
  }        
 }
}
/* личные сообщения */
  

/* email */
function mail_address(user,domain,zone) {
document.write(user+'@'+domain+'.'+zone);
}

function mail_send(user,domain,zone) {
document.location.href = 'mailto:'+user+'@'+domain+'.'+zone;
}
/* email */

function textwrap(textw,countertext) { 
	var textw,tt,countertext,whichtyped; 
	tt = document.getElementById(textw).value; 
	whichtyped = tt; 
	ttr = tt.length+1;
	
	if (ttr > countertext) { 
		alert('Максимальная длина - '+countertext+' символов!'); 
		ttr=countertext; 
		document.getElementById(textw).value = tt.substring(0, countertext - 1); 
	} else {
		document.getElementById('number').value = countertext-(tt.length+1);
	}
}

function submForm3($text,count) {
   
	var ta = document.getElementById($text);
	 if ( ta.value.length <= 3000 ) return true;
	 alert( "Сообщение должно содержать не более 3000  символов , а у вас их " + ta.value.length );
	return false;
}	

function cfm(obj) 
{
        var txt = obj.href;
        txt = txt.replace(/http:\/\/([A-Za-z0-9_\-\.]+)[^>]*/ig , "$1");
        if (txt == 'go2promo.ru' || txt == 'www.go2promo.ru') return;
        else return confirm('Вы собираетесь перейти на сайт: '+ txt + '\nМы не несем ответственности за содержимое этого сайта. \nОткрыть сайт?');
}

function cfm2(obj) 
{
        var txt = obj;
        txt = txt.replace(/http:\/\/([A-Za-z0-9_\-\.]+)[^>]*/ig , "$1");

        if (txt == 'go2promo.ru' || txt == 'www.go2promo.ru' || txt == 'catalog.go2promo.ru' 
        || txt == 'persons.go2promo.ru' || txt == 'job.go2promo.ru' || txt == 'complaint.go2promo.ru' 
        || txt == 'sale.go2promo.ru' || txt == 'news.go2promo.ru' || txt == 'competitions.go2promo.ru'
        || txt == 'polls.go2promo.ru' || txt == 'blogs.go2promo.ru'|| txt == 'community.go2promo.ru'
        || txt == 'forms.go2promo.ru'){
        	window.opener.location = obj;
        	//location = obj;
        }
        else { 
        	if (confirm('Вы собираетесь перейти на сайт: '+ txt + '\nМы не несем ответственности за содержимое этого сайта. \nОткрыть сайт?')){ 
        		window.opener.location = obj;
        		//window.open(obj);
        	}
        }
}

function setElementOpacity(sElemId, nOpacity)
{
  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);

  if (!elem || !opacityProp) return; // Если не существует элемент с указанным id или браузер не поддерживает ни один из известных функции способов управления прозрачностью
  
  if (opacityProp=="filter")  // Internet Exploder 5.5+
  {
    nOpacity *= 100;
	
    // Если уже установлена прозрачность, то меняем её через коллекцию filters, иначе добавляем прозрачность через style.filter
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="
  }
  else // Другие браузеры
    elem.style[opacityProp] = nOpacity;
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
    return 'opacity';
  else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8 
    return 'MozOpacity';
  else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
    return 'KhtmlOpacity';
  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
    return 'filter';

  return false; //нет прозрачности
}

  $(document).ready(function(){
 	  
  $("#sms-img td").mouseout( function() {
  $("#sms-img td").css("background","URL(/templates/default/images1/sms-direct.gif)");
  });
  
  $("#sms-img td").mouseover( function() {
  $("#sms-img td").css("background","URL(/templates/default/images1/sms-direct2.gif)");
  });
  	
  if (getCookie("BlueCookie")==1)
  {
  	//$("#upphone td").css("background","URL(/templates/default/images1/header_blue.gif)");
  	$("#upphone td").css("background","URL(/templates/default/images1/header_blue_newyear.gif)");
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone3.png');
  	$("#icon_hot").attr('src','/templates/default/images1/hot.gif');
  }
  
  if (getCookie("GreyCookie")==1)
  {
  	//$("#upphone td").css("background","URL(/templates/default/images1/header_grey.gif)");
  	$("#upphone td").css("background","URL(/templates/default/images1/header_grey_newyear.gif)");
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone3.png');
  	$("#icon_hot").attr('src','/templates/default/images1/hot1.gif');
  }
  
  $("#BlueCookie").click(function () {
  
  	//$("#upphone td").css("background","URL(/templates/default/images1/header_blue.gif)");
  	$("#upphone td").css("background","URL(/templates/default/images1/header_blue_newyear.gif)");
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone3.png');
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone.png');
  	$("#icon_hot").attr('src','/templates/default/images1/hot.gif');
  	
  	setCookie("BlueCookie",1,604800,'/',hostname);
  	setCookie("GreyCookie",0,604800,'/',hostname);

  });
  
  $("#GreyCookie").click(function () {
  
  	//$("#upphone td").css("background","URL(/templates/default/images1/header_grey.gif)");
  	$("#upphone td").css("background","URL(/templates/default/images1/header_grey_newyear.gif)");
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone3.png');
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone.png');
  	$("#icon_hot").attr('src','/templates/default/images1/hot1.gif');
  
  	
  	setCookie("BlueCookie",0,604800,'/',hostname);
  	setCookie("GreyCookie",1,604800,'/',hostname);
  
  });
  
  $("#BlueCookie").mouseover( function() {
  if (getCookie("BlueCookie")==1)
  {
  	$("#BlueCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone3.png');
  	$("#BlueCookie").animate({opacity:"show"},"fast");
    });
  }
  else
  {
  	$("#BlueCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone2.png');
  	$("#BlueCookie").animate({opacity:"show"},"fast");
  	});
  }
  });
  
  $("#GreyCookie").mouseover( function() {
  if (getCookie("GreyCookie")==1)
  {
  	$("#GreyCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone3.png');
  	$("#GreyCookie").animate({opacity:"show"},"fast");
    });
  }
  else
  {
  	$("#GreyCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone2.png');
  	$("#GreyCookie").animate({opacity:"show"},"fast");
  	});
  }
  });
  
  $("#BlueCookie").mouseout( function() {
  if (getCookie("BlueCookie")==1)
  {
  	$("#BlueCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone3.png');
  	$("#BlueCookie").animate({opacity:"show"},"fast");
    });
  }
  else
  {
  	$("#BlueCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#BlueCookie > img").attr('src','/templates/default/images1/bluephone.png');
  	$("#BlueCookie").animate({opacity:"show"},"fast");
  	});
  }
  });
  
  $("#GreyCookie").mouseout( function() {
  if (getCookie("GreyCookie")==1)
  {
  	$("#GreyCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone3.png');
  	$("#GreyCookie").animate({opacity:"show"},"fast");
    });
  }
  else
  {
  	$("#GreyCookie").animate({opacity:"hide"},"fast" , function() {
  	$("#GreyCookie > img").attr('src','/templates/default/images1/greyphone.png');
  	$("#GreyCookie").animate({opacity:"show"},"fast");
  	});
  }
  });
  
  $("#icon-home").mouseover( function() {
  	$("#icon-home").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-home > img").attr('src','/templates/default/images1/icon-home1.gif');
  	$("#icon-home").animate({opacity:"show"},"fast");
  });
  });
  
  $("#icon-home").mouseout( function() {
  	$("#icon-home").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-home > img").attr('src','/templates/default/images1/icon-home.gif');
  	$("#icon-home").animate({opacity:"show"},"fast");
  });
  });
  
  $("#icon-contacts").mouseover( function() {
  	$("#icon-contacts").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-contacts > img").attr('src','/templates/default/images1/icon-contacts1.gif');
  	$("#icon-contacts").animate({opacity:"show"},"fast");
  });
  });
  
  $("#icon-contacts").mouseout( function() {
  	$("#icon-contacts").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-contacts > img").attr('src','/templates/default/images1/icon-contacts.gif');
  	$("#icon-contacts").animate({opacity:"show"},"fast");
  });
  });
  
  $("#icon-search").mouseover( function() {
  	$("#icon-search").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-search > img").attr('src','/templates/default/images1/icon-search1.gif');
  	$("#icon-search").animate({opacity:"show"},"fast");
  });
  });
  
  $("#icon-search").mouseout( function() {
  	$("#icon-search").animate({opacity:"hide"},"fast" , function() {
  	$("#icon-search > img").attr('src','/templates/default/images1/icon-search.gif');
  	$("#icon-search").animate({opacity:"show"},"fast");
  });
  });
  
  $("#enter").mouseover( function() {
  	$("#enter").attr('src','/templates/default/images1/enter2.gif');
  });
  
  $("#enter").mouseout( function() {
  	$("#enter").attr('src','/templates/default/images1/enter1.gif');
  });
  
  $("#registr").mouseover( function() {
  	$("#registr").attr('src','/templates/default/images1/registr2.gif');
  });
  
  $("#registr").mouseout( function() {
  	$("#registr").attr('src','/templates/default/images1/registr1.gif');
  });
  
  $("#back_page").mouseover( function() {
  	$("#back_page").attr('src','/templates/default/images1/back_page2.gif');
  });
  
  $("#back_page").mouseout( function() {
  	$("#back_page").attr('src','/templates/default/images1/back_page.gif');
  });
  
  /* разбиение на страницы */
  $("#forward_page").mouseover( function() {
  	$("#forward_page").attr('src','/templates/default/images1/forward_page2.gif');
  });
  
  $("#forward_page").mouseout( function() {
  	$("#forward_page").attr('src','/templates/default/images1/forward_page.gif');
  });
  
  $("#other_page").mouseover( function() {
  	$("#other_page > img").attr('src','/templates/default/images1/other_page2.gif');
  });
  
  $("#other_page").mouseout( function() {
  	$("#other_page > img").attr('src','/templates/default/images1/other_page.gif');
  });
  
  $("#other_page").click(function () {
  	$("#sel_page").show(700);
  });
  
  $("#person_foto").mouseout( function() {
  $("#person_foto").attr('src','/templates/default/images1/down1.gif');
  });
  
  $("#person_foto").mouseover( function() {
  $("#person_foto").attr('src','/templates/default/images1/down2.gif');
  });
  /* разбиение на страницы */
  
  /* левое меню */
  var menu_person = 2;
  var menu_company = 2;
  var menu_calendar = 2;
    
  $("#menu_person").click( function() { 
        var parentID = $(this).parents('div').attr('id'); 
        $("#" + parentID + " > .menu").slideToggle( 'fast' );
        
        if (getCookie("menu_person")==1) menu_person = 1;
        else
        {
        	if (getCookie("menu_person")==2) menu_person = 2;
        	else menu_person = 1;
        }
        
        if (menu_person==1)
        {
        	menu_person = 2;
        	$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_person&value=2&expires=604800");       	
        }
        else 
        {
        	menu_person = 1;
        	$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_person&value=1&expires=604800");        	
        }        
  });
  
   $("#menu_company").click( function() { 
        var parentID = $(this).parents('div').attr('id'); 
        $("#" + parentID + " > .menu").slideToggle( 'fast' );
        
        if (getCookie("menu_company")==1) menu_company = 1;
        else
        {
        	if (getCookie("menu_company")==2) menu_company = 2;
        	else menu_company = 1;
        }
        
        if (menu_company==1) 
        {
        	menu_company = 2;
        	$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_company&value=2&expires=604800");        	
        }
        else 
        {
        	menu_company = 1;
        	$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_company&value=1&expires=604800");  
        }
  });  
   
   $("#menu_calendar").click( function() { 
	   var parentID = $(this).parents('div').attr('id'); 
	   var rem = getCookie("remind_" + parentID);
	   var today = Date();
	   var year = today.substr(today.toString().search(/[0-9]{4}/),4);
	   
	   if (getCookie("menu_calendar") == 1) menu_calendar = 1;
       else 
       {
    	   if (getCookie("menu_calendar") == 2) menu_calendar = 2;	
           else menu_calendar = 1;    	   
       }	   
       
	   if (menu_calendar == 1) 
       {
		   menu_calendar = 2;	
		   $(this).attr('src','/templates/default/images1/calendar_down.gif');
	       	
		   $.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_calendar&value=2&expires=604800"
			   );        	
       }
       else 
       {
    	   menu_calendar = 1;	
    	   $(this).attr('src','/templates/default/images1/calendar_up.gif');
    	    
    	   $.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_calendar&value=1&expires=604800");  
       }
	   
	   $.get("/inc/calendar.php?id=" + parentID + "&start_year=" + year + "&show_rem=" + rem +"&show_cal="+ menu_calendar+ "&datebook=calendar_container", 
				  function(data){
				  	$("#calendar_container").html(data);
	   });	   
   });
   
   $("#menu_forms").click( function() { 
       var parentID = $(this).parents('div').parents('div').attr('id'); 
       $("#" + parentID + " > .menu").slideToggle( 'fast' );
       
       if (getCookie("menu_forms")==1) menu_forms = 1;
       else
       {
       	if (getCookie("menu_forms")==2) menu_forms = 2;
       	else menu_forms = 1;
       }
       
       if (menu_forms==1) 
       {
			$(this).attr('src','/templates/default/images1/calendar_down.gif');
			menu_forms = 2;
			$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_forms&value=2&expires=604800");        	
       }
       else 
       {
			$(this).attr('src','/templates/default/images1/calendar_up.gif');
			menu_forms = 1;
			$.get("/inc/ajax_cookies.php?action=set_cookie&name=menu_forms&value=1&expires=604800");  
       }
  });  
    
  $("#remind").click( function() { 
	  var parentID = $(this).parents('div').attr('id'); 
	  
	  $("#" + parentID).attr('style','display:none');	  
  }); 

  /* левое меню */
  
  /* кнопка добавить файл */
  $("#down_doc").mouseout( function() {
  $("#down_doc").attr('src','/templates/default/images1/down_doc1.gif');
  });
  
  $("#down_doc").mouseover( function() {
  $("#down_doc").attr('src','/templates/default/images1/down_doc2.gif');
  });
  /* кнопка добавить файл */
  
  /* кнопка добавить сообщение */
  $("#add_msg").mouseout( function() {
  $("#add_msg").attr('src','/templates/default/images1/add_msg1.gif');
  });
  
  $("#add_msg").mouseover( function() {
  $("#add_msg").attr('src','/templates/default/images1/add_msg2.gif');
  });
  /* кнопка добавить сообщение */
  
  /* кнопка сохранить */
  $("#save").mouseout( function() {
  $("#save").attr('src','/templates/default/images1/save1.gif');
  });
  
  $("#save").mouseover( function() {
  $("#save").attr('src','/templates/default/images1/save2.gif');
  });  
   /* кнопка сохранить */
  
  /* стрелки на стене */
  $("#id_walls_1").mouseout( function() {
  $("#id_walls_1").attr('src','/templates/default/images1/str_wall_3.gif');
  });
  
  $("#id_walls_1").mouseover( function() {
  $("#id_walls_1").attr('src','/templates/default/images1/str_wall_4.gif');
  });
  
  $("#id_walls_2").mouseout( function() {
  $("#id_walls_2").attr('src','/templates/default/images1/str_wall_5.gif');
  });
  
  $("#id_walls_2").mouseover( function() {
  $("#id_walls_2").attr('src','/templates/default/images1/str_wall_6.gif');
  });
  /* стрелки на стене */
  
  /* стрелки на фото */
  $("#id_photo_1").mouseout( function() {
  $("#id_photo_1").attr('src','/templates/default/images1/str_wall_3.gif');
  });
  
  $("#id_photo_1").mouseover( function() {
  $("#id_photo_1").attr('src','/templates/default/images1/str_wall_4.gif');
  });
  
  $("#id_photo_2").mouseout( function() {
  $("#id_photo_2").attr('src','/templates/default/images1/str_wall_5.gif');
  });
  
  $("#id_photo_2").mouseover( function() {
  $("#id_photo_2").attr('src','/templates/default/images1/str_wall_6.gif');
  });
  /* стрелки на фото */
  
  });
  
  function calendar_next_month(id,year,month,cal,return_field){
	  var rem = getCookie("remind_" + id);
	  
	  $.get("/inc/calendar.php?id=" + id + "&start_year=" + year + "&start_month=" + month + "&show_rem=" + rem + "&datebook=" + cal+ "&return_field="+ return_field, 
		  function(data){
		  	$("#" + cal).html(data);		  	   
	  });
  } 
  
  function calendar_date(cont,return_field){
	  var cont_cal = document.getElementById(cont);
	  var date     = document.getElementById(return_field).value;
	  var today    = new Date();
	  var arr_data = new Array;
	  
	  if (date != '' && /(\d{2})\.(\d{2})\.(\d{4})/.test(date)){
		arr_data = date.split('.');
	  }
	  else{
		arr_data = new Array(today.getDate(),today.getMonth()+1,today.getFullYear());
	  }
	
	  cont_cal.innerHTML = '';
	  $.get("/inc/calendar.php?start_year=" + Number(arr_data[2]) + "&start_month=" + Number(arr_data[1]) + "&start_day=" + Number(arr_data[0]) + "&datebook=" + cont +"&return_field=" + return_field, 
			  function(data){
			  	$("#" + cont).html(data);});
	  
	  if(cont_cal.style.display == '' || cont_cal.style.display == 'none'){
	  
		  cont_cal.style.display = 'block';	  	
	  }	  
	  else{
		  cont_cal.style.display = 'none';
	  }
		  
	  
  } 
  function return_date(date,return_field,cont){  
	  
	  document.getElementById(return_field).value = date;
	  document.getElementById(cont).style.display = 'none';
	  
  }  
  
  function budget_pie(id,action,from,curr){
	  var start_date = document.getElementById('start_date_' + action).value; 
	  var end_date   = document.getElementById('end_date_' + action).value;	  
	  var period     = document.getElementById('period_' + action);
	  var img        = document.getElementById('img_' + action);	 
	  var arr_data   = new Array;
	  var today      = new Date();
	  var count_day  = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	  	  
	  if (from == 'date' && start_date != '' &&  end_date != ''){
		  var tmp = 1;  
		  arr_start_date = start_date.split('.');
		  arr_end_date   = end_date.split('.');
			
		  start_date = arr_start_date[2] + '-' + arr_start_date[1] + '-' + arr_start_date[0];
		  end_date   = arr_end_date[2]   + '-' + arr_end_date[1]   + '-' + arr_end_date[0];
	  }
	  else if (from == 'period'){
		  var tmp = 0;
		  for (var i=0;i<period.options.length;i++){
		        if (period.options[i].selected){ 
		        	period_name = period.options[i].text;
		        	period_id   = period.options[i].value;
		        }
		  }
		  
		  if (today.getMonth()< 9){ var month = '0' + (today.getMonth() + 1);}
			else {var month = today.getMonth() + 1;}
		  
		  switch (period_name){
			  case 'вся':
				    start_date = '1970-01-01';
				    end_date   = '2038-01-19';
					break;					
				case 'за текущую неделю':
					if (today.getDay() == 0){ var dw = 6; }								
					else {var dw = today.getDay() - 1;}
					
					if ((today.getDate() - dw)< 10){ var start_day = '0' + (today.getDate() - dw);}
					else {var start_day = today.getDate() - dw;}
					
					if ((today.getDate() - dw + 6)< 10){ var end_day = '0' + (today.getDate() - dw + 6);}
					else {var end_day = today.getDate() - dw + 6;}
					
					var start_year  = today.getFullYear();
					var start_month = month;
					
					if(end_day > count_day[today.getMonth() + 1]){
						if (today.getMonth() != 11){
							var end_month = (today.getMonth()< 8)? '0' + (today.getMonth() + 2): today.getMonth() + 2;	
							var end_year  = start_year;
						}
						else{
							var end_year  = start_year + 1;
							var end_month = '01';							
						}
						end_day	= end_day - count_day[today.getMonth() + 1];
					}
					else{
						var end_month = start_month;
						var end_year  = start_year; 
					}
					
					start_date = start_year  + '-' + start_month  + '-' + start_day; 
					end_date   = end_year    + '-' + end_month    + '-' + end_day;						
					break;					
				case 'за текущий месяц':				
					start_date = today.getFullYear() + '-' + month + '-01'; 
					end_date   = today.getFullYear() + '-' + month + '-' + (count_day[today.getMonth()]);
					break;
								
				case 'за текущий год':				
					start_date = today.getFullYear() + '-01-01'; 
					end_date   = today.getFullYear() + '-12-31';										
					break;			
			  }			 
	  }
	  
	  $.get("/pChart/index.php?id=" + id + "&do=" + action + "&curr=" + curr + "&start_date=" + start_date + "&end_date=" + end_date + "&tmp=" + tmp, 
		  function(data){
		  $("#img_" + action).attr('src', data.split(";")[0]);
		  $("#total_" + action + "_amount").html(data.split(";")[1]);
	  });	  
  } 