function openVerMenu(mid){
	if($("#vsubmenu_"+mid).css("display")=="none"){
		$("#vsubmenu_"+mid).show(200);
		$("#vmenu_group_"+mid).css("background","#f1f4f0");
		saveOpenedMenu(mid,1);
	}else{
		$("#vsubmenu_"+mid).hide(200);
		$("#vmenu_group_"+mid).css("background","none");
		saveOpenedMenu(mid,0);
	}
}
function saveOpenedMenu(mid,stat){
	 $.ajax({
	   type: "get",
	   url: saveMenuScript,
	   data: "mid="+mid+"&stat="+stat,
	   success: function(msg){
		 void(0);
	   }
	 });
}
$(document).ready(function() {

	
	$("#outer").height($("#body").height($(window).height()));
	if($("#main_block").height()<($("#body").height()-295))$("#main_block").height($("#body").height()-330);

	$('input[type=text][title!=""]').each(function() {
	if ($.trim($(this).val()) == '') $(this).val($(this).attr('title'));
	if ($(this).val() == $(this).attr('title')) $(this).addClass('exampleText');
	}).focus(switchText).blur(switchText);
	$("a.zoom").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
 
 $('a.blank_').click( function() {
      window.open(this.href);
      return false;
  });
  $('a._blank').click( function() {
      window.open(this.href);
      return false;
  });
  $('.sticker').hover( function() {
      $(this).children().toggle();
  });
	$('input[type=checkbox]').change(function(){
		if($(this).is(":checked")){
			$("label[for="+$(this).attr("id")+"]").addClass("LabelSelected");
			//$(this).next("label").addClass("LabelSelected");
		}else{
			$("label[for="+$(this).attr("id")+"]").removeClass("LabelSelected");
			//$(this).next("label").removeClass("LabelSelected");
		}
	});
	/*$(".shipping_radio").change(function(){  
    if($(this).is(":checked")){ 
      $("input[name="+$(this).attr("name")+"]").next("label").removeClass("RadioSelected");  
        $(this).next("label").addClass("RadioSelected");  
    }  
	});*/ 
	$(".shipping_radio").change(function(){  
    if($(this).is(":checked")){ 
      $(".shipping_radio").next("label").removeClass("RadioSelected");  
        $(this).next("label").addClass("RadioSelected");  
    }  
	}); 
	$(".shipping_radio2").change(function(){  
    if($(this).is(":checked")){ 
      $(".shipping_radio2").next("label").removeClass("RadioSelected");  
        $(this).next("label").addClass("RadioSelected");  
    }  
	}); 	
	if($('.amount_elem').val()){
		amount=$('.amount_elem').sum();
		$('#total_amount_b').html(amount.toFixed(2));
		pvnl=Number(pvnl);
		pvnt=(amount*pvnl)/100;
		$('#total_amount_p').html(pvnt.toFixed(2));
		total=amount+pvnt;
		$('#total_amount').html(total.toFixed(2));
		//alert(pvnl);
		//total=amount*100/(100+pvnl);
		//total_amount_b=amount*100/(100+pvnl);
		//alert(total_amount_b);
		//total2=amount-total;
	}
	total_amount();
	window.setTimeout(function() {
		$('.skype_pnh_container').html('');
		$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
	}, 800);
	if($('#links'))$('#links').val(window.location.pathname)
});
function switchText(){
	if ($(this).val() == $(this).attr('title'))
		$(this).val('').removeClass('exampleText');
	else if ($.trim($(this).val()) == '')
		$(this).addClass('exampleText').val($(this).attr('title'));
}
function renval(price,quantity,element,element2){
	amount=price*quantity;
	$(element).val(amount.toFixed(2));
	$(element2).html(amount.toFixed(2));
}
function showval(val){
	string=$('#'+val).val();
	arrajs = string.split('\\');
	$('#'+val+'_val').show();
	$('#'+val+'_val').html(arrajs[arrajs.length-1]);
}


function ajax_sendnews(link, container, value,name) {
	if(value != ''){
		$.ajax({
			url : link,
			data : { email:value,action:'asdsa', name:name },
			type : 'post',
			success : function(msg){
				$('#'+container).html(msg).fadeIn(100);
			//	$('#'+container).fadeOut(60000);
			}
		});
	}else{
		$.ajax({
			url : link,
			data : { action:'none'},
			type : 'post',
			success : function(msg){
				$('#'+container).html(msg).fadeIn(100);
		//		$('#'+container).fadeOut(60000);
			}
		});
	}
}

function prodplus(){
	jQuery.each($('.elem_three_quantity'), function() {
				$(this).val(parseInt($(this).val())+1);
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[1];
				rezz=$('#elem_three_price_'+rez).html()*$('#quant3_'+rez).val()
				$('#elem_amount3_'+rez).val(rezz.toFixed(2));
				$('#elem_three_show_'+rez).html(rezz.toFixed(2));
   });
}
function prodminus(){
	jQuery.each($('.elem_three_quantity'), function() {
				if($(this).val()>0)$(this).val(parseInt($(this).val())-1);
				$(this).next('.amount_elem').val();
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[1];
				rezz=$('#elem_three_price_'+rez).html()*$('#quant3_'+rez).val()
				$('#elem_amount3_'+rez).val(rezz.toFixed(2));
				$('#elem_three_show_'+rez).html(rezz.toFixed(2));
   });
}
function prodsum(tt){
	if($('.amount_elem').val()){
		amount=$('.amount_elem').sum();
		$('#total_amount_b').html(amount.toFixed(2));
		pvnl=Number(pvnl);
		//alert(pvnl);
		pvnt=(amount*pvnl)/100;
		$('#total_amount_p').html(pvnt.toFixed(2));
		total=amount+pvnt;
		$('#total_amount').html(total.toFixed(2));
		//total=amount*100/(100+pvnl);
		//total_amount_b=amount*100/(100+pvnl);
		//alert(total_amount_b);
		//$('#total_amount_b').html(total.toFixed(2));
		//total2=amount-total;
		//$('#total_amount_p').html(total2.toFixed(2));
	}
}

function prodfun(pr,ty,va,vvv){
	qu=parseInt($('#quant_'+ty+'_'+pr).val());
	if(va == '+'){
		if(!vvv)$('#quant_'+ty+'_'+pr).val(qu+1);
		if(ty<3)jQuery.each($('.el_3_q'), function() {
				$(this).val(parseInt($(this).val())+1);
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[2];
				rezz=$('#price_3_'+rez).val()*$('#quant_3_'+rez).val();
				$('#amount_3_'+rez).val(rezz.toFixed(2));
				$('#show_3_'+rez).html(rezz.toFixed(2));
	   });
	   
		if(vvv>3)jQuery.each($('.sub_pr'), function() {
				$(this).val(parseInt($(this).val())+1);
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[2];
				rezz=$('#price_3_'+rez).val()*$('#quant_3_'+rez).val();
				$('#amount_3_'+rez).val(rezz.toFixed(2));
				$('#show_3_'+rez).html(rezz.toFixed(2));
	   });
	}else if($('#quant_'+ty+'_'+pr).val()>0 && va == '-'){
		if(!vvv)$('#quant_'+ty+'_'+pr).val(qu-1);
		if(ty<3)jQuery.each($('.el_3_q'), function() {
				if($(this).val()>0)$(this).val(parseInt($(this).val())-1);
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[2];
				rezz=$('#price_3_'+rez).val()*$('#quant_3_'+rez).val();
				$('#amount_3_'+rez).val(rezz.toFixed(2));
				$('#show_3_'+rez).html(rezz.toFixed(2));
	   });
		if(vvv>3)jQuery.each($('.sub_pr'), function() {
				if($(this).val()>0)$(this).val(parseInt($(this).val())-1);
				rez=$(this).attr('id');
				rez=rez.split('_');				
				rez=rez[2];
				rezz=$('#price_3_'+rez).val()*$('#quant_3_'+rez).val();
				$('#amount_3_'+rez).val(rezz.toFixed(2));
				$('#show_3_'+rez).html(rezz.toFixed(2));
	   });
	}
	qu=parseInt($('#quant_'+ty+'_'+pr).val());
	prc=$('#price_'+ty+'_'+pr).val();
	amount=prc*qu;
	$('#amount_'+ty+'_'+pr).val(amount.toFixed(2));
	$('#show_'+ty+'_'+pr).html($('#amount_'+ty+'_'+pr).val());
	amount=$('.amount_elem').sum();
	$('#total_amount_b').html(amount.toFixed(2));
	pvnl=Number(pvnl);
	pvnt=(amount*pvnl)/100;
	$('#total_amount_p').html(pvnt.toFixed(2));
	total=amount+pvnt;
	$('#total_amount').html(total.toFixed(2));
	//alert(pvnl);
	//total=amount*100/(100+pvnl);
	//total_amount_b=amount*100/(100+pvnl);
	//alert(total_amount_b);
	//$('#total_amount_b').html(total.toFixed(2));
	//total2=amount-total;
	//$('#total_amount_p').html(total2.toFixed(2));
}

function remove_row(link,type,row){
	$.ajax({
	  url: link+'?remove=1&type='+type+'&row='+row,
	  success: function(data) {
	  	$('#row_'+type+'_'+row).remove();
			amount=$('.amount_elem').sum();
			$('#total_amount_b').html(amount.toFixed(2));
			pvnl=Number(pvnl);
			pvnt=(amount*pvnl)/100;
			$('#total_amount_p').html(pvnt.toFixed(2));
			total=amount+pvnt;
			$('#total_amount').html(total.toFixed(2));
			//alert(pvnl);
			//total=amount*100/(100+pvnl);
			//total_amount_b=amount*100/(100+pvnl);
			//alert(total_amount_b);
			//$('#total_amount_b').html(total.toFixed(2));
			//total2=amount-total;
			//$('#total_amount_p').html(total2.toFixed(2));
	  }
	});
}
function notchan(link,type,row){
	val=$('#notes_'+type+'_'+row).val();
	$.ajax({
	  url: link+'?notchan=1&val='+val+'&row='+type+'_'+row,
	  success: function(data) {
	  }
	});
}
function get_delivery(link,weight){
	val=$('#shipping_cityregion1').val();
	val=encodeURI(val);
//	alert(val);
	$.ajax({
	  url: link+'?get_delivery=1&val='+val+'&weight='+weight,
	  success: function(data) {
	  	$('#delivery_price2').val(data);
	  	$('.delivery_price').html(data);
			total_amount();
	  }
	});
}
function total_amount(){
	if($('.amount_elem').val()){
		amount = Number($('#delivery_price2').val())+$('.amount_elem').sum();
		$('#total_amount_b2').html(amount.toFixed(2));
		//total=amount*100/(100+Number(pvnl));
		//$('#total_amount_b2').html(total.toFixed(2));
		//total2=amount-total;
		//$('#total_amount_p2').html(total2.toFixed(2))
		pvnt=(amount*pvnl)/100;
		$('#total_amount_p2').html(pvnt.toFixed(2));
		total=amount+pvnt;
		$('#total_amount2').html(total.toFixed(2));
	}
}

function adbask(link,type,row,vvv){
	val=$('#quant_'+type+'_'+row).val();
	$.ajax({
	  url: link+'?adbask=1&val='+val+'&row='+type+'_'+row,
	  success: function(data) {
	  }
	});
	if(type<3)jQuery.each($('.el_3_q'), function() {
			rez=$(this).attr('id');
			rez=rez.split('_');				
			rez=rez[2];
			rezz=$('#quant_3_'+rez).val();
			$.ajax({
			  url: link+'?adbask=1&val='+rezz+'&row=3_'+rez,
			  success: function(data) {
			  }
			});
   });
	if(vvv==4)jQuery.each($('.sub_pr'), function() {
			rez=$(this).attr('id');
			rez=rez.split('_');				
			rez=rez[2];
			rezz=$('#quant_3_'+rez).val();
			$.ajax({
			  url: link+'?adbask=1&val='+rezz+'&row=3_'+rez,
			  success: function(data) {
			  }
			});
   });
}
function shipping(){
	if($('input[name=shipping_question]:checked').val() == 'yes') $('#transport_div').show();
	else $('#transport_div').hide();
	if($('input[name=shipping_question]:checked').val() == 'yes') $('.delivery_st').show();
	else $('.delivery_st').hide();
	if($('input[name=shipping_question]:checked').val() == 'yes') $('.delivery_st3').hide();
	else $('.delivery_st3').show();
}

