document.write("<style>.dn { display: none; }</style>");

support_phone='+7 ' + '(47' + '32)' + ' 2' + '0-59-25';	
support_email='<a href="mailto:support@satspace.ru">su'+'pp'+'or'+'t'+'@'+'satspace'+'.ru</a>';	
support_adress='г.Воронеж, ул. 45 Стрелковой Дивизии, д.125';

function save_server(cookie_name, cookie_value) {
	$.cookie(cookie_name, cookie_value);
}

function imgopen(pic) {
	fenster = open("", "Anzeige", "width=1000,height=635");
	fenster.document.open();
	with (fenster.document) {
	 write("<html><body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>");
	 write("<img src='../../img/maps/macro/");
	 write(pic);
	 write("' align='center'>");
	 write("</body></html>");
	}
	fenster.document.close();
} 

// заменяет все тарифы и значения
function button_tariff(butt) {
	//alert(butt);
	$('span[id*=valute]').each(function(el) { 
		p=$(this).attr(butt);
		$(this).html(p);
	});
	
	
}

function replace_all(per, val) {
	$('span[id="'+per+'"]').each(function(el) { 
		$(this).html(val);
	});
}

// подсвечивает кнопку
function select_button(th, butt) {
	//alert('BUTT: '+butt);	
	vvalue=$(th).attr("vvalue");
	$('a[type="'+butt+'"]').each(function() { 
		$(this).removeAttr('class');
		if ($(this).attr("vvalue")==vvalue) {
			$(this).attr("class", "select");		
		}
	});	
	if ($(th).attr("vvalue")=="RUB") { replace_all('view_valute', 'руб.'); }
	if ($(th).attr("vvalue")=="USD") { replace_all('view_valute', 'у.е.'); }
	if ($(th).attr("vvalue")=="MB") { replace_all('view_size', 'Мб'); }
	if ($(th).attr("vvalue")=="GB") { replace_all('view_size', 'Гб'); }
}

// кнопка с выбором спутника
function select_button_sputnik(th, butt) {
	$('li').each(function() {	
		if ($(this).attr("ttype")==butt) $(this).removeAttr('class');
		if ($(this).attr("vvalue")==$(th).attr("vvalue")) $(this).attr("class", "selected");
	});
}

// заменить все тексты для спутников
function replace_texts_sputnik(this_sputnik) {
	$('span[id="view_text"]').each(function(el) { 
		tx=$(this).attr("txt_"+this_sputnik);
		$(this).html(tx);
	});
}


// нажатие на размер или на валюту
$(document).ready(function(){
	// сворачивание тарифов
	$('a[type="PODROBNO"]').click(function () {
		$('div[id="d'+$(this).attr("vvalue")+'"]').slideToggle("normal");
		$("#podrbutton"+$(this).attr("vvalue")).slideToggle("normal");
		$("#podrbr"+$(this).attr("vvalue")).attr("class", "dn");
	 });

	$('a[type="SIZE"]').click(function() {
		this_size=$(this).attr("vvalue");
		button_tariff(this_sputnik+this_usd+'_'+this_size);
		select_button(this, "SIZE");
		save_server('SIZE', this_size);
	});

	$('a[type="VALUTE"]').click(function() {
		this_usd=$(this).attr("vvalue");
		button_tariff(this_sputnik+this_usd+'_'+this_size);
		select_button(this, "VALUTE");
		save_server('VALUTE', this_usd);
	});
			
	$('a[type="SPUTNIK"]').click(function() {
		this_sputnik=$(this).attr("vvalue");
		//alert('CLICK SPUTNIK:'+this_sputnik);
		select_button_sputnik(this, "SPUTNIK");
		button_tariff(this_sputnik+this_usd+'_'+this_size);
		replace_texts_sputnik(this_sputnik);
		replace_all('view_sputnik_name', "&nbsp;<small>["+$(this).attr("ttitle")+"]</small>");
		$('div[rel="block_select"]').removeAttr("class");
		$("#bl2_"+this_sputnik).attr("class", "select_block2");
		return false;
	});	
	
	// кнопки 88х31
	$('a[class="click88x31"]').click(function () {
		main_host=$('#img_padding').attr('host');
		$('#out_html').text('<!-- Партнер SatSpace.Ru -->\n<a href="http://'+main_host+'/" title="Партнер SatSpace.Ru"><img width="88" height="31" align="texttop" border="0" src="http://'+main_host+'/_img/88x31/'+$(this).attr("num")+'.gif"></a>\n<!-- /Партнер SatSpace.Ru -->');
	 });	

});

// вспл подсказка
function l_tooltip(target_items, name){
	jQuery(target_items).each(function(i){
		jQuery("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+jQuery(this).attr('title')+"</p></div>");
		var tooltip = jQuery("#"+name+i);

		jQuery(this).removeAttr("title").mouseover(function(){
			tooltip.css({opacity:0.9, display:"none"}).fadeIn(30);
		}).mousemove(function(kmouse){
			tooltip.css({left:kmouse.pageX+15, top:kmouse.pageY+15});
		}).mouseout(function(){
			tooltip.fadeOut(10);
		});
	});
}

$(document).ready(function(){
	l_tooltip("[hint=1]","tooltip");
});

// lightbox
$(function() {
	$('a[rel*=lightbox]').lightBox(); // выбираете все ссылки которые содержат слово lightbox в аттрибуте rel
	$('img[rel*=lightbox]').lightBox(); // выбираете все ссылки которые содержат слово lightbox в аттрибуте rel
});  
