var WinOpen;

function my_go (target){
	if(target!=undefined && target!="" && target!=0){
		location.href=target;
	}
}

function clean_basket(text,link){
	if (confirm(text)) {
		document.update_basket.submit();
	}
}

function hideIt(id){
	if(document.getElementById(id).style.display=="none"){

		document.getElementById(id).style.display="block";

	}else{
		document.getElementById(id).style.display="none";
	}
}

function show_img(title, img_src, img_width, img_height, pad) {
 	height = parseInt(img_height) + 30;
 	width = parseInt(img_width) + 30;

	p_top=(screen.height-img_height)/2-30;
	p_left=(screen.width-img_width)/2+Number(pad);

    if(WinOpen != null){
     	  WinOpen.close();
          WinOpen  =  window.open("", "Foto", "closed=yes, toolbar=no, location=no, top="+p_top+", left="+p_left+", directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+width+", height="+height+"");
    }else{
          WinOpen  =  window.open("", "Foto", "closed=yes, toolbar=no, location=no, top="+p_top+", left="+p_left+", directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+width+", height="+height+"");
}
    if(WinOpen != null){
          WinOpen  =  window.open("", "Foto", "closed=yes, toolbar=no, location=no, top="+p_top+", left="+p_left+", directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+width+", height="+height+"");
          WinOpen.document.write("<html><head><title>"+title+"</title>");
          WinOpen.document.write("<SCRIPT language=javascript>function cl() { close(); }</SCRIPT></head>");
          WinOpen.document.write("<body style='padding:0; margin:0;' bgcolor='#E5E5E5'><table width='100%' height='100%'><tr><td align='center' style='vertical-align:middle;'><img src="+img_src+" style='cursor:pointer;' alt=\"Закрыть\" onClick=\"cl()\"; style='BORDER-RIGHT: white 4px solid; BORDER-TOP: white 4px solid; BORDER-LEFT: white 4px solid; BORDER-BOTTOM: white 4px solid'></td></tr></table></body></html>");
    }

return WinOpen;

}

function show_hide(id,sid){

		document.getElementById(id).style.display="block";
		document.getElementById(sid).style.display="none";

}

var last_id='info_block_0';

function show_this_deactive_last(id){

		document.getElementById(last_id).style.display="none";
		last_id=id;
		document.getElementById(id).style.display="block";

}

function CalculateLeaders(){

	document.getElementById('display_gifts').style.display='none';

	document.getElementById('calc_gifts').style.display='none';
	document.getElementById('or_another').style.display='none';

	document.getElementById('gift_5').style.display='none';
	document.getElementById('gift_4').style.display='none';
	document.getElementById('gift_3').style.display='none';
	document.getElementById('gift_2').style.display='none';
	document.getElementById('gift_1').style.display='none';

	if(document.getElementById('f_consult').value=="") document.getElementById('f_consult').value="0";
	if(document.getElementById('s_consult').value=="") document.getElementById('s_consult').value="0";

	if(document.getElementById('s_consult').value==""){

		show_hide('calc_info','calc');
		document.getElementById('s_hits').value="0";
		document.getElementById('all_hits').value="0";

	}else if(document.getElementById('s_consult').value=="0"){

		show_hide('calc_info','calc');
		document.getElementById('s_hits').value="0";
		document.getElementById('all_hits').value="0";

	}else{

		document.getElementById('f_hits').value=Math.floor(Number(document.getElementById('f_consult').value)*3);
		document.getElementById('s_hits').value=Math.floor(Number(document.getElementById('s_consult').value)*1);
		document.getElementById('all_hits').value=Math.floor(Number(document.getElementById('f_hits').value))+Math.floor(Number(document.getElementById('s_hits').value));
	
		hits=document.getElementById('all_hits').value;

		if(hits>49) document.getElementById('gift_5').style.display='block';
		if(hits>199){ document.getElementById('gift_4').style.display='block'; document.getElementById('or_another').style.display='block'; }
		if(hits>399) document.getElementById('gift_3').style.display='block';
		if(hits>599) document.getElementById('gift_2').style.display='block';
		if(hits>999) document.getElementById('gift_1').style.display='block';

		document.gifts_amount.gifts_amount_1.value=Math.floor(Number(hits)/1000);
		document.gifts_amount.gifts_amount_2.value=Math.floor(Number(hits)/600);
		document.gifts_amount.gifts_amount_3.value=Math.floor(Number(hits)/400);
		document.gifts_amount.gifts_amount_4.value=Math.floor(Number(hits)/200);
		document.gifts_amount.gifts_amount_5.value=Math.floor(Number(hits)/50);

		document.gifts_amount.your_hits.value="Вы набрали "+hits+" Платиновых Хитов. Вы можете выбрать:";

		if(hits>49) document.getElementById('display_gifts').style.display='block';

	}

}

function CalculateSponsors(){

	document.getElementById('display_gift_1').style.display='none'; document.getElementById('display_gift_2').style.display='none'; document.getElementById('display_gift_3').style.display='none';

	if(document.getElementById('f_consult').value==""){ document.getElementById('f_consult').value="0"; document.getElementById('f_hits').value="0"; }
	if(document.getElementById('s_consult').value==""){ document.getElementById('s_consult').value="0"; document.getElementById('s_hits').value="0"; }

	if(document.getElementById('s_consult').value==""){

		show_hide('calc_info','calc');
		document.getElementById('s_hits').value="0";
		document.getElementById('all_hits').value="0";

	}else if(document.getElementById('s_consult').value=="0"){

		show_hide('calc_info','calc');
		document.getElementById('s_hits').value="0";
		document.getElementById('all_hits').value="0";

	}else{

		document.getElementById('f_hits').value=Math.floor(Number(document.getElementById('f_consult').value)*3);
		document.getElementById('s_hits').value=Math.floor(Number(document.getElementById('s_consult').value)*1);
		document.getElementById('all_hits').value=Math.floor(Number(document.getElementById('f_hits').value))+Math.floor(Number(document.getElementById('s_hits').value));
	
		hits=document.getElementById('all_hits').value;

		if(hits>=2 && hits<=4) document.getElementById('display_gift_3').style.display='block';
		else
		if(hits>=5 && hits<=24) document.getElementById('display_gift_2').style.display='block';
		else
		if(hits>=25) document.getElementById('display_gift_1').style.display='block';

	}
}

function S_ShowGifts(){

	if(document.getElementById('s_fsteps').value>=1 && document.getElementById('s_fsteps').value<3){
		document.getElementById('s_new_consult_calc').style.display="none";
		document.getElementById('s_new_consult_1_3').style.display="block";
	}

	if(document.getElementById('s_fsteps').value>=3 && document.getElementById('s_fsteps').value<5){
		document.getElementById('s_new_consult_calc').style.display="none";
		document.getElementById('s_new_consult_3_5').style.display="block";
	}

	if(document.getElementById('s_fsteps').value>=5){
		document.getElementById('s_new_consult_calc').style.display="none";
		document.getElementById('s_new_consult_5').style.display="block";
	}

}

