function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ = new XMLHttpRequest();
	}
	return request_;
}

var http_next_similar_products = createRequestObject();

var cur_similar_products=-10;
var cur_similar_products_info='';
var cur_similar_products_active=0;

function next_similar_products( product_id, lang, info, max, url ){
	
	
	
if(cur_similar_products_active==0){

	cur_similar_products_active=1;
	
	if(info==2 && cur_similar_products==-10){
		cur_similar_products=4;
		cur_similar_products_info=info;
	}
	
	if(info==1 && cur_similar_products==-10){
		cur_similar_products=max;
		cur_similar_products_info=info;
	}

	if(cur_similar_products_info!=info){
		if(info==2){
			cur_similar_products=parseInt(cur_similar_products)+4;
			if(parseInt(cur_similar_products)>parseInt(max)){
				cur_similar_products=(parseInt(cur_similar_products)-parseInt(max));
			}
		}else{
			cur_similar_products=parseInt(cur_similar_products)-4;
			if(parseInt(cur_similar_products)<0){
				cur_similar_products=(parseInt(max)+parseInt(cur_similar_products));
			}
		}
		cur_similar_products_info=info;
	}

	

	http_next_similar_products.open('get', 'http://'+url+'/ajax_next_product.php?product_id='+product_id+'&lang='+lang+'&info='+info+'&cur_similar_products='+cur_similar_products+'&z='+Math.random());
	http_next_similar_products.onreadystatechange = next_similar_products_handleInfo;
	http_next_similar_products.send(null);
	
	if(info==2){
		if(cur_similar_products==max){
			cur_similar_products=1;
		}else{
			cur_similar_products++;
		}
	}else{
		if(cur_similar_products==0){
			cur_similar_products=parseInt(max)-1;
		}else{
			cur_similar_products--;
		}
	}
	
	
	}
	
}

function next_similar_products_handleInfo(){

	if(http_next_similar_products.readyState == 4){

		var response = http_next_similar_products.responseText;
		full_info=response.split('*');
		
		if(full_info[0]==2){
			document.getElementById('similar_product_1').innerHTML = document.getElementById('similar_product_2').innerHTML;
			document.getElementById('similar_product_2').innerHTML = document.getElementById('similar_product_3').innerHTML;
			document.getElementById('similar_product_3').innerHTML = document.getElementById('similar_product_4').innerHTML;
			document.getElementById('similar_product_4').innerHTML = full_info[1];
		}else{
			document.getElementById('similar_product_4').innerHTML = document.getElementById('similar_product_3').innerHTML;
			document.getElementById('similar_product_3').innerHTML = document.getElementById('similar_product_2').innerHTML;
			document.getElementById('similar_product_2').innerHTML = document.getElementById('similar_product_1').innerHTML;
			document.getElementById('similar_product_1').innerHTML = full_info[1];
		}
		cur_similar_products_active=0;
	}
}




var http_next_promotion_products = createRequestObject();

var cur_promotion_products=-10;
var cur_promotion_products_info='';
var cur_promotion_products_active=0;

function next_promotion_products( lang, info, max, url ){
	
if(cur_promotion_products_active==0){

	cur_promotion_products_active=1;
	
	if(info==2 && cur_promotion_products==-10){
		cur_promotion_products=4;
		cur_promotion_products_info=info;
	}
	
	if(info==1 && cur_promotion_products==-10){
		cur_promotion_products=max;
		cur_promotion_products_info=info;
	}

	if(cur_promotion_products_info!=info){
		if(info==2){
			cur_promotion_products=parseInt(cur_promotion_products)+4;
			if(parseInt(cur_promotion_products)>parseInt(max)){
				cur_promotion_products=(parseInt(cur_promotion_products)-parseInt(max));
			}
		}else{
			cur_promotion_products=parseInt(cur_promotion_products)-4;
			if(parseInt(cur_promotion_products)<0){
				cur_promotion_products=(parseInt(max)+parseInt(cur_promotion_products));
			}
		}
		cur_promotion_products_info=info;
	}

	

	http_next_promotion_products.open('get', 'http://'+url+'/ajax_promotion_product.php?lang='+lang+'&info='+info+'&cur_promotion_products='+cur_promotion_products+'&z='+Math.random());
	http_next_promotion_products.onreadystatechange = next_promotion_products_handleInfo;
	http_next_promotion_products.send(null);
	
	if(info==2){
		if(cur_promotion_products==max){
			cur_promotion_products=1;
		}else{
			cur_promotion_products++;
		}
	}else{
		if(cur_promotion_products==0){
			cur_promotion_products=parseInt(max)-1;
		}else{
			cur_promotion_products--;
		}
	}
	
	
	}
	
}

function next_promotion_products_handleInfo(){

	if(http_next_promotion_products.readyState == 4){

		var response = http_next_promotion_products.responseText;
		full_info=response.split('*');
		
		if(full_info[0]==2){
			document.getElementById('promotion_product_1').innerHTML = document.getElementById('promotion_product_2').innerHTML;
			document.getElementById('promotion_product_2').innerHTML = document.getElementById('promotion_product_3').innerHTML;
			document.getElementById('promotion_product_3').innerHTML = document.getElementById('promotion_product_4').innerHTML;
			document.getElementById('promotion_product_4').innerHTML = full_info[1];
		}else{
			document.getElementById('promotion_product_4').innerHTML = document.getElementById('promotion_product_3').innerHTML;
			document.getElementById('promotion_product_3').innerHTML = document.getElementById('promotion_product_2').innerHTML;
			document.getElementById('promotion_product_2').innerHTML = document.getElementById('promotion_product_1').innerHTML;
			document.getElementById('promotion_product_1').innerHTML = full_info[1];
		}
		cur_promotion_products_active=0;
	}
}


function view_np(x, input_id){
		
		if(x==1){
			document.getElementById('nalojen_platej_other').style.display='none';
			document.getElementById('nalojen_platej_speedy').style.display='block';
			document.getElementById('speedy_np').style.display='block';
			
			document.getElementById('spiddy_office_div1').style.display='none';
			document.getElementById('spiddy_office_text1').style.display='block';
			document.getElementById('spiddy_office_div2').style.display='none';
			document.getElementById('spiddy_office_text2').style.display='block';
			
			document.getElementById('supplier_name').value='';
			document.getElementById('supplier_info').value='';
			
			if(input_id==1){
				document.getElementById('spiddy_office_div1').style.display='block';
				document.getElementById('spiddy_office_text1').style.display='none';
			}
			if(input_id==2){
				document.getElementById('spiddy_office_div2').style.display='block';
				document.getElementById('spiddy_office_text2').style.display='none';
			}
	
		}else{
			document.getElementById('nalojen_platej_other').style.display='block';
			document.getElementById('nalojen_platej_speedy').style.display='none';
			document.getElementById('speedy_np').style.display='none';
			
			document.getElementById('spiddy_office_div1').style.display='none';
			document.getElementById('spiddy_office_text1').style.display='block';
			document.getElementById('spiddy_office_div2').style.display='none';
			document.getElementById('spiddy_office_text2').style.display='block';
		}
}


function popitup(url, wname, height, width, hm) {
	
	if (window.innerHeight && window.scrollMaxY) {// Firefox

				yWithScroll = window.innerHeight + window.scrollMaxY;

				xWithScroll = window.innerWidth + window.scrollMaxX;

			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac

				yWithScroll = document.body.scrollHeight;

				xWithScroll = document.body.scrollWidth;

			} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari

				yWithScroll = document.body.offsetHeight;

				xWithScroll = document.body.offsetWidth;

	}
	
	cur_yWithScroll=200;
	cur_xWithScroll=(xWithScroll-width)/2;
	
	
		
	newwindow=window.open(url, wname,'height='+height+',width='+width+',top='+cur_yWithScroll+',left='+cur_xWithScroll);
	if (window.focus) {newwindow.focus()}
	
	
	
	if(hm!=1){
	
		return false;
	
	}else{
		
		return true;
		
	}
	
}


var http_show_selected_option_info_city = createRequestObject();


function show_selected_option_info_city( option_text, div_id, id, lang, spiddy_office,  url){
	

	
	document.getElementById(div_id).innerHTML=option_text;

	http_show_selected_option_info_city.open('get', 'https://'+url+'/ajax_supply_info_city.php?city='+id+'&lang='+lang+'&spiddy_office='+spiddy_office+'&z='+Math.random());
	http_show_selected_option_info_city.onreadystatechange = show_selected_option_info_city_handleInfo;
	http_show_selected_option_info_city.send(null);
	
}

function show_selected_option_info_city_handleInfo(){

	if(http_show_selected_option_info_city.readyState == 4){

		var response = http_show_selected_option_info_city.responseText;

		full_info=response.split('*');
		
		if(full_info[0]!=''){
			
			if(full_info[0]==1){
				
				
				document.getElementById('spiddy_office_div1').innerHTML = full_info[1];
				document.getElementById('spiddy_office_div2').innerHTML = full_info[2];
				
				document.getElementById('supply_radio_tr_1').style.display='block';
				document.getElementById('supply_radio_tr_2').style.display='block';
				document.getElementById('supply_radio_tr_4').style.display='block';
				
				document.getElementById('supply_3_1').style.display='block';
				document.getElementById('supply_3_price1').style.display='block';
				document.getElementById('supply_3_2').style.display='none';
				document.getElementById('supply_3_price2').style.display='none';
				
				document.getElementById('price_1_address_info').value='1';
				
			}else{
				document.getElementById('supply_3_1').style.display='none';
				document.getElementById('supply_3_price1').style.display='none';
				document.getElementById('supply_3_2').style.display='block';
				document.getElementById('supply_3_price2').style.display='block';
				
				document.getElementById('supply_radio_1').checked = false;
				document.getElementById('supply_radio_2').checked = false;
				document.getElementById('supply_radio_tr_1').style.display='none';
				document.getElementById('supply_radio_tr_2').style.display='none';
				document.getElementById('supply_radio_tr_4').style.display='none';
				
				document.getElementById('price_1_address_info').value='2';
				
				document.getElementById('spiddy_office_div1').style.display='none';
				document.getElementById('spiddy_office_text1').style.display='block';
				document.getElementById('spiddy_office_div2').style.display='none';
				document.getElementById('spiddy_office_text2').style.display='block';
			}
		}

	}
}


var http_ajax_close_livechat = createRequestObject();


function ajax_close_livechat(url){

	http_ajax_close_livechat.open('get', 'http://'+url+'/ajax_close_livechat.php?z='+Math.random());
	http_ajax_close_livechat.onreadystatechange = ajax_close_livechat_handleInfo;
	http_ajax_close_livechat.send(null);
	
}

function ajax_close_livechat_handleInfo(){

	if(http_ajax_close_livechat.readyState == 4){

		var response = http_ajax_close_livechat.responseText;
		
		if(response==1){
		
		document.getElementById('feedback').innerHTML='<div id="feedback_top"><a href="javascript:void(window.open(\'http://bravite.com/livezilla/chat.php\',\'\',\'width=590,height=610,left=0,top=0,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes\'))"><img src="http://bravite.com/livezilla/image.php?id=07" width="81" height="24" border="0" alt="LiveZilla Live Help"></a><noscript><div><a href="http://bravite.com/livezilla/chat.php" target="_blank">Start Live Help Chat</a></div></noscript></div>';
		}
		
	}
}

function close_feedback(){
	document.getElementById('feedback').style.display='none';
	setTimeout("view_feedback()", 20000);
}

function view_feedback(){
	document.getElementById('feedback').style.display='block';
}


function show_hide (x){
	if(x==1){
		document.getElementById('invoice1').style.display='block';
		document.getElementById('invoice2').style.display='none';
	}else{
		if(x==2){
			document.getElementById('invoice1').style.display='none';
			document.getElementById('invoice2').style.display='block';
		}else{
			document.getElementById('invoice1').style.display='none';
			document.getElementById('invoice2').style.display='none';
		}
	}
}

function show_selected_option_info ( option_text, div_id){

	document.getElementById(div_id).innerHTML=option_text;
	
}

function form_submit ( info ){
	
	if(document.getElementById('full_product_weight').value!=''){

		document.getElementById('form_submit').click();
	
	}else{
		alert(info);
	}
	
}

function form_submit2 ( info ){
	
	if( document.getElementById('select_city').value!='' || document.getElementById('city_name').value!='' ){

		document.getElementById('form_submit').click();
	
	}else{
		alert(info);
	}
	
}


function show_selected_option_info2 ( option_text, div_id, id){

	document.getElementById(div_id).innerHTML=option_text;
	
	if(id!='BG'){
		document.getElementById('diff_country').style.display='block';
		document.getElementById('supply_table').style.display='none';
		document.getElementById('city_name').style.display='block';
		document.getElementById('select_cart_info_cities').style.display='none';
		document.getElementById('tr_1').style.display='none';
		document.getElementById('tr_4').style.display='none';
		document.getElementById('tr_5').style.display='none';
		
	}else{
		document.getElementById('diff_country').style.display='none';
		document.getElementById('supply_table').style.display='block';
		document.getElementById('city_name').style.display='none';
		document.getElementById('select_cart_info_cities').style.display='block';
		document.getElementById('tr_1').style.display='block';
		document.getElementById('tr_4').style.display='block';
		document.getElementById('tr_5').style.display='block';
		
	}
	
	
}

function show_selected_option_info3 ( option_text, div_id, id){

	document.getElementById(div_id).innerHTML=option_text;
	
	if(id!='BG'){
		
		
		document.getElementById('city_name').style.display='block';
		document.getElementById('select_cart_info_cities').style.display='none';

		
	}else{
		
		
		document.getElementById('city_name').style.display='none';
		document.getElementById('select_cart_info_cities').style.display='block';

		
	}
	
	
}


function show_selected_option_info3 ( option_text, div_id, id){

	document.getElementById(div_id).innerHTML=option_text;
	
	if(id!='BG'){
		document.getElementById('city_name').style.display='block';
		document.getElementById('select_cart_info_cities').style.display='none';
		
	}else{
		document.getElementById('city_name').style.display='none';
		document.getElementById('select_cart_info_cities').style.display='block';		
	}
	
}


var show_hide_add_search_flaf=0;

function show_hide_add_search (){

	if(show_hide_add_search_flaf==0){
		document.getElementById('add_search_inputs').style.display='block';
		document.getElementById('search_but').style.display='none';
		document.getElementById('search_close_but').style.display='block';
		document.getElementById('search_arrow_but').style.display='none';
		show_hide_add_search_flaf=1;
	}else{
		document.getElementById('add_search_inputs').style.display='none';
		document.getElementById('search_close_but').style.display='none';
		document.getElementById('search_arrow_but').style.display='block';
		document.getElementById('search_but').style.display='block';
		show_hide_add_search_flaf=0;
	}
	
}

function active_checkbox(checkbox_number){
	
	var input_number=document.getElementById('product_count'+checkbox_number).value;
	if(input_number==''){
		document.getElementById('product_checkbox'+checkbox_number).click();
		document.getElementById('product_count_div'+checkbox_number).style.display='none';
	}
}


function check_checkbox(checkbox_id){
		document.getElementById(checkbox_id).click();
}

function click_checkbox(checkbox_number){
	var input_number=document.getElementById('product_count'+checkbox_number).value;
	if(input_number!=''){
		document.getElementById('product_count'+checkbox_number).value='';
		document.getElementById('product_count_div'+checkbox_number).style.display='block';
		total_price_generate3(checkbox_number, '1');
	}else{
		document.getElementById('product_count'+checkbox_number).disabled='';
		document.getElementById('product_count_div'+checkbox_number).style.display='none';
		document.getElementById('product_count'+checkbox_number).value='1';
		total_price_generate3(checkbox_number, '0');
	}
}

function total_price_generate(){
	var product_cur_price=document.getElementById('product_cur_price').value;
	var product_count_but=document.getElementById('product_count_but').value;
	var total_price;

	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
		if(product_count_but=='' || parseFloat(product_count_but)<=0 || isNaN(parseFloat(product_count_but))){
			product_count_but=1;
			document.getElementById('product_count_but').value=1;
			document.getElementById('product_count_but').select();
		}
		
		total_price=Math.round((parseFloat(product_cur_price)*parseFloat(product_count_but))*100)/100;
		document.getElementById('total_price').innerHTML=total_price;
	}
}

function total_price_generate_distr(info){
	var product_cur_price=document.getElementById('product_cur_price').value;
	var product_cur_distr_price=document.getElementById('product_cur_distr_price').value;
	var product_count_but=document.getElementById('product_count_but').value;

	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
		if(product_count_but=='' || parseFloat(product_count_but)<=0 || isNaN(parseFloat(product_count_but))){
			product_count_but=1;
			document.getElementById('product_count_but').value=1;
			document.getElementById('product_count_but').select();
		}
		
		total_price=Math.round((parseFloat(product_cur_price)*parseFloat(product_count_but))*100)/100;
		if(total_price>info && product_cur_price!=product_cur_distr_price){
			total_price=Math.round((parseFloat(product_cur_distr_price)*parseFloat(product_count_but))*100)/100;
		}
		document.getElementById('total_price').innerHTML=total_price;
	}
}

function total_price_generate3(info, end){

		product_count_but=document.getElementById('product_count'+info).value;
		product_count_but_old=document.getElementById('product_count_old'+info).value;
		product_cur_price=document.getElementById('product_cur_price'+info).value;
		var total_price;
			
if(product_count_but!=product_count_but_old){
		
	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
		if(end!=1){
			if(product_count_but=='' || parseFloat(product_count_but)<=0 || isNaN(parseFloat(product_count_but))){
				product_count_but=1;
				document.getElementById('product_count'+info).value=1;
				document.getElementById('product_count'+info).select();
			}
		}else{
			product_count_but=0;
		}
		
		cur_total_price=document.getElementById('total_price').innerHTML;
		
		cur_total_price=parseFloat(cur_total_price)-parseInt(product_count_but_old)*parseFloat(product_cur_price);
		
		if(product_count_but_old>product_count_but){
											
				total_price=Math.round((parseFloat(cur_total_price)+parseFloat(product_cur_price)*parseInt(product_count_but))*100)/100;	
				document.getElementById('total_price').innerHTML=total_price;
			
		}else{
						
				total_price=Math.round((parseFloat(cur_total_price)+parseFloat(product_cur_price)*parseInt(product_count_but))*100)/100;	
				document.getElementById('total_price').innerHTML=total_price;
		}
	
		document.getElementById('product_count_old'+info).value=product_count_but;
		
	}
	}
	if(end==1){
			document.getElementById('product_count'+info).disabled=true;
	}
}





var my_act_codes=new Array();

function click_checkbox2(checkbox_number){
	var input_number=document.getElementById('product_count'+checkbox_number).value;
	if(input_number!=''){
		document.getElementById('product_count'+checkbox_number).value='';
		document.getElementById('product_count_div'+checkbox_number).style.display='block';
		total_price_generate31(checkbox_number, '1');
		
		var idx = my_act_codes.indexOf(checkbox_number); // Find the index
		if(idx!=-1) my_act_codes.splice(idx, 1); // Remove it if really found!
	}else{
		document.getElementById('product_count'+checkbox_number).disabled='';
		document.getElementById('product_count_div'+checkbox_number).style.display='none';
		document.getElementById('product_count'+checkbox_number).value='1';
		total_price_generate31(checkbox_number, '2');
		
		my_act_codes_length=my_act_codes.length;
		my_act_codes[my_act_codes_length]=checkbox_number;
		
	}
}

function total_price_generate31(info, end){

		product_count_but=document.getElementById('product_count'+info).value;
		real_product_count_but=product_count_but;
		
		product_count_but_old=document.getElementById('product_count_old'+info).value;
		product_cur_price=document.getElementById('product_cur_price'+info).value;
		product_cur_price_distr=parseFloat(document.getElementById('product_cur_price_distr'+info).value);
		
		cur_get_products_sum_value=parseFloat(document.getElementById('cur_get_products_sum_value').value);
		
		real_cur_get_products_sum_value=cur_get_products_sum_value;
			
if(product_count_but!=product_count_but_old){
		
	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
		 
		if(end!=1){
			if(end==2 ){
				product_count_but=1;
				document.getElementById('product_count'+info).value=1;
				document.getElementById('product_count'+info).select();
				real_product_count_but=product_count_but;
				
			}
			
		}else{
			
			product_count_but=0;
			real_product_count_but=product_count_but;
		}
		
		cur_total_price=document.getElementById('total_price').innerHTML;
		
		real_cur_total_price=cur_total_price;
		
		next=0;
		real_total_price=0;
		
		if(cur_get_products_sum_value>=0){
			
			cur_total_price=parseFloat(real_cur_total_price)-parseInt(product_count_but_old)*parseFloat(product_cur_price);
								
			total_price=Math.round((parseFloat(cur_total_price)+parseFloat(product_cur_price)*parseInt(product_count_but))*100)/100;
			
			
			real_cur_total_price2=parseInt(product_count_but_old)*parseFloat(product_cur_price_distr);
			
			real_total_price=Math.round((parseFloat(real_cur_total_price2)-parseFloat(product_cur_price_distr)*parseInt(product_count_but))*100)/100;	
			
			cur_get_products_sum_value=real_cur_get_products_sum_value+real_total_price;
			
			if(cur_get_products_sum_value<0){	
				next=1;
			}
			
		}else{

			
			cur_total_price=parseFloat(real_cur_total_price)-parseInt(product_count_but_old)*parseFloat(product_cur_price_distr);
								
			total_price=Math.round((parseFloat(cur_total_price)+parseFloat(product_cur_price_distr)*parseInt(product_count_but))*100)/100;
			
			
			
			real_cur_total_price2=parseInt(product_count_but_old)*parseFloat(product_cur_price_distr);
			
			real_total_price=Math.round((parseFloat(real_cur_total_price2)-parseFloat(product_cur_price_distr)*parseInt(product_count_but))*100)/100;	
			
			cur_get_products_sum_value=real_cur_get_products_sum_value+real_total_price;
			
			if(cur_get_products_sum_value>=0){	
				next=2;
			}
			
		}
		
		if(next==1){
			total_price=0;
			
			if(end==2 ){
				
				total_price=Math.round((parseFloat(total_price)+parseFloat(product_cur_price_distr)*parseInt(product_count_but))*100)/100;
				
			}
			
			my_act_codes_length=my_act_codes.length;
			for(i=0;i<my_act_codes_length;i++){
				for_code_id=my_act_codes[i];
							
				
				product_count_but=document.getElementById('product_count'+for_code_id).value;
				
				product_cur_price_distr=parseFloat(document.getElementById('product_cur_price_distr'+for_code_id).value);
				
				if(product_count_but>0 && product_cur_price_distr>0){
				
				total_price=Math.round((parseFloat(total_price)+parseFloat(product_cur_price_distr)*parseInt(product_count_but))*100)/100;							
				}
			}
			
			
			
		}
		
		if(next==2){
			total_price=0;
			
			my_act_codes_length=my_act_codes.length;
			for(i=0;i<my_act_codes_length;i++){
				for_code_id=my_act_codes[i];
			
				product_count_but=document.getElementById('product_count'+for_code_id).value;
				
				product_cur_price=document.getElementById('product_cur_price'+for_code_id).value;
								
				if(product_count_but>0 && product_cur_price_distr>0){
				
				total_price=Math.round((parseFloat(total_price)+parseFloat(product_cur_price)*parseInt(product_count_but))*100)/100;
								
				}
							
			}
		}
		
		
		
		document.getElementById('cur_get_products_sum_value').value=cur_get_products_sum_value;
		
			document.getElementById('total_price').innerHTML=total_price;

		document.getElementById('product_count_old'+info).value=real_product_count_but;
		
	}
	}
	if(end==1){
			document.getElementById('product_count'+info).disabled=true;
	}
}

function total_price_generate2(){
	var max_input_info=parseInt(document.getElementById('number_m').value);	
	var info_yes=0;
	for(i=0;i<max_input_info;i++){
		info=document.getElementById('product_count'+i).value;
		if(info!=''){
			info_yes=1;
		}
	}

	if(info_yes==0){
		alert('Моля изберете продукт');
		return false;
	}else{
		return true;
	}
	
}

var old_cur_pic=0;

function view_big_pic(cur_pic_id, all_product_pic_br, product_main_pic_yes){

	if(product_main_pic_yes==0 && old_cur_pic==0){
		old_cur_pic=1;
	}
	
	document.getElementById('cur_pic_'+old_cur_pic).style.display='none';
	document.getElementById('cur_pic'+old_cur_pic).style.display='none';
	document.getElementById('cur_pic_second'+old_cur_pic).style.display='none';
		
	document.getElementById('cur_pic_'+cur_pic_id).style.display='block';
	document.getElementById('cur_pic'+cur_pic_id).style.display='block';
	document.getElementById('cur_pic_second'+cur_pic_id).style.display='block';
	
	old_cur_pic=cur_pic_id;
}

function dll_code( info, msg ) {
	if(confirm(msg)){
		document.getElementById('dll_code').value=info;
		document.getElementById('form_send_info').submit();
	}
}

function go_to_link( info, msg ) {
	if(confirm(msg)){
		top.location=info;
	}
}


var start_price_generate_timer='';

function start_total_price_generate4( info, code_id, url ){
	
	if(start_price_generate_timer!=''){
		clearTimeout(start_price_generate_timer);
	}
		
	start_price_generate_timer = setTimeout("total_price_generate4( '"+info+"', '"+code_id+"', '"+url+"' )", 300);
}



var http_total_price_generate4 = createRequestObject();
var cur_cart_element=0;
var cur_cart_element_count=0;

function total_price_generate4( info, code_id, url ){
	
	start_price_generate_timer='';

	cur_cart_element=info;
	
	product_count_but=document.getElementById('product_count'+info).value;
		product_count_but_old=document.getElementById('product_count_old'+info).value;
		product_cur_price=document.getElementById('product_cur_price'+info).value;
			
if(product_count_but!=product_count_but_old){
		
	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
			if(product_count_but=='' || parseFloat(product_count_but)<=0 || isNaN(parseFloat(product_count_but))){
				product_count_but=1;
				document.getElementById('product_count'+info).value=1;
				document.getElementById('product_count'+info).select();
			}
			
			product_weight=(parseInt(document.getElementById('product_weight'+info).value)/1000);
			
			old_product_weight=Math.round(product_weight*product_count_but_old*100)/100;
			
			cur_product_weight=Math.round(product_weight*product_count_but*100)/100;
			
			document.getElementById('cur_product_weight'+info).innerHTML = parseFloat(cur_product_weight);
			full_product_weight = Math.round(((parseFloat(document.getElementById('total_product_weight').innerHTML)-parseFloat(old_product_weight))+parseFloat(cur_product_weight))*100)/100;
			 document.getElementById('total_product_weight').innerHTML = full_product_weight
			
			 document.getElementById('full_product_weight').value=full_product_weight;
					
		cur_total_price=parseFloat(document.getElementById('view_total_price').innerHTML);
		
		document.getElementById('product_count_old'+info).value=product_count_but;
		
		http_total_price_generate4.open('get', 'http://'+url+'/ajax_cart_info.php?code_id='+code_id+'&product_count_but='+product_count_but+'&product_count_but_old='+product_count_but_old+'&product_cur_price='+product_cur_price+'&cur_total_price='+cur_total_price+'&z='+Math.random());
		http_total_price_generate4.onreadystatechange = total_price_generate4_handleInfo;
		http_total_price_generate4.send(null);
	}
	
}



}

function total_price_generate4_handleInfo(){
	

	if(http_total_price_generate4.readyState == 4){

		var response = http_total_price_generate4.responseText;
		
		cur_cart_element_count=0;
		
		full_info=response.split('*');
		
			document.getElementById('cur_total_price'+cur_cart_element).innerHTML = full_info[1];
					
					
			document.getElementById('view_total_price').innerHTML = full_info[0];

			
			document.getElementById('total_br').innerHTML = parseInt(document.getElementById('total_br').innerHTML) - parseInt(full_info[2]);
			
			
			
	}
}




var start_price_generate5_timer='';

function start_total_price_generate5( info, code_id, url ){
	
	if(start_price_generate5_timer!=''){
		clearTimeout(start_price_generate5_timer);
	}
		
	start_price_generate5_timer = setTimeout("total_price_generate5( '"+info+"', '"+code_id+"', '"+url+"' )", 300);
}



var http_total_price_generate5 = createRequestObject();
var cur_cart_element5=0;
var cur_cart_element5_count=0;

function total_price_generate5( info, code_id, url ){
	
	start_price_generate5_timer='';

	cur_cart_element5=info;
	
		product_count_but=document.getElementById('product_count'+info).value;
		product_count_but_old=document.getElementById('product_count_old'+info).value;
		product_cur_price=document.getElementById('product_cur_price'+info).value;
		product_cur_price_distr=document.getElementById('product_cur_price_distr'+info).value;
		
		cur_get_products_sum_value=document.getElementById('cur_get_products_sum_value').value;
		lang=document.getElementById('lang').value;
			
if(product_count_but!=product_count_but_old){
		
	if(product_cur_price!='' && parseFloat(product_cur_price)>=0){
			if(product_count_but=='' || parseFloat(product_count_but)<=0 || isNaN(parseFloat(product_count_but))){
				product_count_but=1;
				document.getElementById('product_count'+info).value=1;
				document.getElementById('product_count'+info).select();
			}
			
			product_weight=(parseInt(document.getElementById('product_weight'+info).value)/1000);
			
			old_product_weight=Math.round(product_weight*product_count_but_old*100)/100;
			
			cur_product_weight=Math.round(product_weight*product_count_but*100)/100;
			
			document.getElementById('cur_product_weight'+info).innerHTML = parseFloat(cur_product_weight);
			
			full_product_weight = Math.round(((parseFloat(document.getElementById('total_product_weight').innerHTML)-parseFloat(old_product_weight))+parseFloat(cur_product_weight))*100)/100;
			
			document.getElementById('total_product_weight').innerHTML = full_product_weight
			
			document.getElementById('full_product_weight').value=full_product_weight;
					
		cur_total_price=parseFloat(document.getElementById('view_total_price').innerHTML);
		
		document.getElementById('product_count_old'+info).value=product_count_but;
		
		
		
		http_total_price_generate5.open('get', 'http://'+url+'/ajax_cart_info2.php?code_id='+code_id+'&product_count_but='+product_count_but+'&product_count_but_old='+product_count_but_old+'&product_cur_price='+product_cur_price+'&cur_total_price='+cur_total_price+'&lang='+lang+'&cur_get_products_sum_value='+cur_get_products_sum_value+'&product_cur_price_distr='+product_cur_price_distr+'&z='+Math.random());
		http_total_price_generate5.onreadystatechange = total_price_generate5_handleInfo;
		http_total_price_generate5.send(null);
	}
	
}



}

function total_price_generate5_handleInfo(){
	

	if(http_total_price_generate5.readyState == 4){

		
		var response = http_total_price_generate5.responseText;
		
			cur_cart_element5_count=0;
		
			full_info=response.split('*');
			
			if(full_info[0]=='0'){
				
				
		
				document.getElementById('cur_total_price'+cur_cart_element5).innerHTML = full_info[2];
						
						
				document.getElementById('view_total_price').innerHTML = full_info[1];
	
				
				document.getElementById('total_br').innerHTML = parseInt(document.getElementById('total_br').innerHTML) - parseInt(full_info[3]);
				
				document.getElementById('cur_get_products_sum_value').value=full_info[4];
			
				
			}else{
				
				document.getElementById('cart_table_div').innerHTML = full_info[1];
				
			}
	}
}




var http_add_product_to_cookie = createRequestObject();

function add_product_to_cookie ( product_id, url, lang ){

	http_add_product_to_cookie.open('get', 'http://'+url+'/ajax_add_product_to_cookie.php?product_id='+product_id+'&url='+url+'&lang='+lang+'&z='+Math.random());
	http_add_product_to_cookie.onreadystatechange = add_product_to_cookie_handleInfo;
	http_add_product_to_cookie.send(null);
	
}

function add_product_to_cookie_handleInfo(){

	if(http_add_product_to_cookie.readyState == 4){

		var response = http_add_product_to_cookie.responseText;
		document.getElementById('product_more_info_add_notebook').innerHTML = response;
		
	}
}

function clear_all_price_filter (){
	
	document.getElementById('all_price_filter_none').click();
	document.getElementById('price_filter_1').value='';
	document.getElementById('price_filter_2').value='';
	document.getElementById('price_form').submit();
}

function clear_producter_form (){
	
	document.getElementById('all_producter').click();
	document.getElementById('producter_form').submit();
}

var cur_click_radio=0;

function click_radio(info){
	if(cur_click_radio!=info){
	
	cur_click_radio=info;
	
	document.getElementById('supply_radio_'+info).click();
	
	}
}

var mark_rating_flag=0;

function cur_rating(info){
	if(mark_rating_flag==0){
		if(info==1){
		
			document.getElementById('new_rating_div').style.display='block';
			document.getElementById('cur_rating_div').style.display='none';
					
		}else{
			
			document.getElementById('new_rating_div').style.display='none';
			document.getElementById('cur_rating_div').style.display='block';
			
		}
	}else{
		mark_rating(mark_rating_flag);
	}
	
}

function mark_rating(info){
		if(info==0){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==1 && mark_rating_flag<=1){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==2 && mark_rating_flag<=2){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==3 && mark_rating_flag<=3){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==4 && mark_rating_flag<=4){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_empty.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==5 && mark_rating_flag<=5){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_empty.jpg)';
		}
		if(info==6 && mark_rating_flag<=6){
			document.getElementById('mark_star_1').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_2').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_3').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_4').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_5').style.background='url(/images/reiting_star_full.jpg)';
			document.getElementById('mark_star_6').style.background='url(/images/reiting_star_full.jpg)';
		}
		  
	
}


function select_rating(info, cur_value){
	mark_rating_flag=cur_value;
	document.getElementById('send_reiting').selectedIndex=info;
	document.getElementById('select_input_info_inside_1').innerHTML=document.getElementById('send_reiting').options[info].text;
	mark_rating(cur_value);
}

function show_selected_option_info_reiting ( option_text, div_id, info){

	document.getElementById(div_id).innerHTML=option_text;
	
	if(info!=''){
		cur_rating('1');
		mark_rating_flag=info;
		mark_rating(info);
	}else{
		mark_rating_flag=0;
		mark_rating(0);
		cur_rating('2');
	}
	
}

function change_user_activity ( info ){
	document.getElementById('user_activity').value=info;
	document.getElementById('user_activity').focus();
}

function checkEnter(e, form_id){

var characterCode

if(e && e.which){
e = e
characterCode = e.which
}else{
e = event
characterCode = e.keyCode
}

if(characterCode == 13){
document.getElementById(form_id).submit()
return false
}else{
return true
}

}

function checkEnter2(e){

var characterCode

if(e && e.which){
e = e
characterCode = e.which
}else{
e = event
characterCode = e.keyCode
}

if(characterCode == 13){
form_onsubmit();
return false
}else{
return true
}

}

function add_to_info(){
	document.getElementById('form_product_count_add_to_info_submit').click();
}

function check_this_value(info){
	
if(info!=''){
	pass_but_value=document.getElementById('pass_but').value;
	if(pass_but_value!=''){
		document.getElementById('cur_pass').style.display='none';
	}
}else{
	document.getElementById('email_but_input').value='E-mail';
}
	
}

function click_not_act_checkbox(code_name){
	
	document.getElementById('id_code1000').value=code_name;
	document.getElementById('form_submit2').click();
	
}

function this_payment_radio(info) {

			
		if(info!=1){

			document.getElementById('supply_table_tr_1_up').style.display='none';
			document.getElementById('supply_table_tr_2_up').style.display='none';
			
			document.getElementById('supply_radio_1').disabled='';
			document.getElementById('supply_radio_2').disabled='';

				
		}else{
			
			document.getElementById('supply_table_tr_1_up').style.display='block';
			document.getElementById('supply_table_tr_2_up').style.display='block';
			
			document.getElementById('supply_radio_1').disabled='true';
			document.getElementById('supply_radio_2').disabled='true';
				
		}
}

function mark_new_reiting(info){
	if(info!=''){
		cur_rating('1');
		mark_rating_flag=info;
		mark_rating(info);
	}else{
		mark_rating_flag=0;
		mark_rating(0);
		cur_rating('2');
	}
}

function select_rating2(info, cur_value){
	mark_rating_flag=cur_value;
	document.getElementById('send_reiting').selectedIndex=info;
	
	mark_rating(cur_value);
	
}

function setActiveTab(tabID, newclass) {

var currTabElem = document.getElementById(tabID);
/*alert(tabID+','+newclass);*/
currTabElem.setAttribute("class", newclass);
currTabElem.setAttribute("className", newclass);
/*alert(tabID+','+newclass);*/
return;
}

var cur_tab_y_content=0;
var cur_tab_m_content=0;


function view_dif_m_tab(info, info_y){
	
	if(cur_tab_m_content!=info || cur_tab_y_content!=info_y){
		
		setActiveTab('tab_m_menu_content'+info_y+'_'+info, 'active');
		document.getElementById('tab_content_m_'+info_y+'_'+info).style.display='block';
		if(cur_tab_m_content!=0){
			setActiveTab('tab_m_menu_content'+cur_tab_y_content+'_'+cur_tab_m_content, 'unactive');
			document.getElementById('tab_content_m_'+cur_tab_y_content+'_'+cur_tab_m_content).style.display='none';
		}
		cur_tab_m_content=info;
		
	}
}
function view_dif_tab(info){
	
	if(cur_tab_y_content!=info){
		
		setActiveTab('tab_lent_menu_content'+info, 'tab_lent_menu2');
		document.getElementById('tab_content'+info).style.display='block';
		if(cur_tab_y_content!=0){
			setActiveTab('tab_lent_menu_content'+cur_tab_y_content, 'tab_lent_menu');
			document.getElementById('tab_content'+cur_tab_y_content).style.display='none';
			view_dif_m_tab('1',info);
			cur_tab_y_content=info;
		}else{
			cur_tab_y_content=info;
			view_dif_m_tab('1',info);
		}

	}
}

function view_cur_tab(info_y, info_c){

		view_dif_tab(info_y);
		view_dif_m_tab(info_c, info_y);
}
