function pics(img,ref)
{
	document.getElementById(img).src = ref;
}

function openwin(img,w,h,title)
{
 var hWnd;
 if(hWnd!=null) hWnd.close();
 hWnd=window.open(img,"","toolbar=no,location=no,directories=no,resizable=yes,scrollbars=yes,left=100,top=100,width="+w+",height="+h);
 hWnd.document.open();
 hWnd.document.write("<html><head><title>"+title+"</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
 hWnd.document.write("<img src=\""+img+"\" width="+w+" height="+h+">");
 hWnd.document.write("</body></html>");
 hWnd.document.close();
}

function IEPngFix(pngimg, gifimg, width, height)
{
	var code = '<img src="'+ gifimg +'" width="' + width + '" height="' + height + '" border="0" style="background:url('+pngimg+') no-repeat 0px 0px;"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="'+gifimg+'" width="' + width + '" height="' + height + '" border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=crop );"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}
function IEPngFix2(pngimg, gifimg, width, height)
{
	var code = '<img src="'+ gifimg +'" width="' + width + '" height="' + height + '" border="0" style="background:url('+pngimg+') no-repeat 0px 0px;"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="'+gifimg+'" width="' + width + '" height="' + height + '" border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=scale );"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}


function switch_class(cn, obj)
{
	obj.className = cn;
}



function show_div(id)
{
	var div;
	div = document.getElementById(id);
	if ( div.style.display == "none" ) div.style.display = "block";
		else div.style.display = "none";
}



//jQuery.noConflict();
function assign(){
//	var jq = jQuery.noConflict();
	var opts = {
				left: 6,
				top: 7,
				blur: 2,
				opacity: 0.8,
				color: '#c4c1b1',
				swap: false
			};

$('.link_date').each(function(){
	$(this).parent().hover(function(){
		hide_hint();
		$(this).append($('#date_title'));
		$(this).css({'backgroundColor': 'white'})
		var text = $(this).find('.metadata').html();
		$('#date_title').empty(); 
		$('#date_title').append(text);
		$('#date_title').css({'display' : 'block'})
		//$('#date_title').dropShadow(opts);
		$('.calendar_line').css({'display':'block'});
	}, function(){
		hide_hint();
		$(this).css({'backgroundColor': '#ffffff'})
	})
})
}

function hide_hint(){
		//$('#date_title').removeShadow();
		 $("#date_title_home").append($('#date_title'));
		$('#date_title').css({'display' : 'none'});
}



/*              ÑÊÐÈÏÒ ÎÒÏÐÀÂÊÈ ÍÀ ÌÛËÎ             */

var email_url="/inc/feedback_popup.php";

var send_mes_flag = 0; 


function ask_send_form(){
	if (send_mes_flag ) return false;
	send_mes_flag  = 1;
	$('#send_mail').fadeIn(300);
}

$(document).ready(function(){
	$('.mail span').mouseover(function(){
		$(this).css({'borderColor':'#ffffff'});
	})
	$('.mail span').mouseout(function(){
		$(this).css({'borderColor':'#C3C3C3'});
	})
	$('.popup_handler').each(function(){
		$(this).css({'cursor':'move'}).draggable();
		$(this).css({'opacity':'0.95'});
		var popup_item=this;
		$('#name_send').attr('value','');
		$('#email_send').attr('value','');
		$('#tel_send').attr('value','');
		$('#theme_send').attr('value','');
		$('#text_send').attr('value','');
		$(this).find('.hide_popup').each(function(){
			$(this).css({'cursor':'pointer'});
			$(this).bind('click', function(){
				send_mes_flag = 0;
				$('#name_send').attr('value','');
				$('#email_send').attr('value','');
				$('#theme_send').attr('value','');
				$('#tel_send').attr('value','');
				$('#text_send').attr('value','');
				$(popup_item).fadeOut(300);
			})
		})
	})
});

function send_mes(){
	var name = $('#name_send').attr('value');
	var email = $('#email_send').attr('value');
	var tel = $('#tel_send').attr('value');
	var theme = $('#theme_send').attr('value');
	var email = $('#email_send').attr('value');
	var text = $('#text_send').attr('value');
	email_url+='?name='+name+'&tel='+tel+'&theme='+theme+'&email='+email+'&text='+text;
	send_mail(email_url);
	email_url = '';
	$('.popup_handler').fadeOut(300);
	$('#mail_send_call').empty().append('ïèñüìî îòïðàâëåíî');
	$('.mail').css({'backgroundImage':'url(/i/ico_mail1.gif)'});
	$('#mail_send_call').css({'cursor':'default', 'color':'#c4c4c4', 'textDecoration': 'none'});
}

function send_mail(url){ 
		//alert(url)
		var req=null;
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.open("GET", url, true);
			req.send(null);
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.open("GET", url, true);
				req.send();
			}
		}
			get_answer();
			function get_answer(){
				/*if(req.readyState==4){
					if (req.responseText!=''){
						var response = req.responseText;
					} 
				}else
					tmer=setTimeout('get_answer();', 200);*/
			}
}

/*             ÃÎÂÎÐßÙÈÉ ×ÅËÎÂÅÊ             */

var newmes_flag = 1;
$(document).ready(function(){
	$('.person').mouseover(function(){
		if (newmes_flag != 0){
			var mes_index = Math.floor(Math.random()*popup_mes.length);
			var mes = popup_mes[mes_index];
			$('.doyouknow .do_you_know_text').empty().append(mes);
			newmes_flag = 0;
		}
		$('.doyouknow').css({'display':'block'});
	})
	$('.person').mouseout(function(e){
		var targ= e.toElement || e.relatedTarget;
		if( ($(targ).hasClass('do_you_know_text')==false)){
			$('.doyouknow').css({ 'display' : 'none' });
			newmes_flag = 1;
		}
	})
	$('.doyouknow').mouseout(function(e){
		var targ= e.toElement || e.relatedTarget;
		if (is_parent(targ,this)) return false;
		if( ($(targ).hasClass('person')==false)){
			$('.doyouknow').css({'display':'none'});
			newmes_flag = 1;
		}
	})
})

function is_parent(child_obj,parent_obj){
	if(!child_obj)return false;
	if(child_obj==parent_obj)return true;
	return is_parent(child_obj.parentNode,parent_obj);
}


/*              ÑÎÐÒÈÐÎÂÊÀ ÊËÈÅÍÒÎÂ È ÐÀÁÎÒ            */

$(document).ready(function(){
	$('.show_list').click(function(){
		$(this).parent().find('.show_pics').css({'display':'inline'});
		$(this).css({'display':'none'});
		$('.pic_list').removeClass('pic_list').addClass('brand_list');
	})
	$('.show_pics').click(function(){
		$('.brand_list').removeClass('brand_list').addClass('pic_list');
		$(this).parent().find('.show_list').css({'display':'inline'});
		$(this).css({'display':'none'});
	})
	$('.show_all_clients').click(function(){
		$('.all_clients_h').removeClass('all_clients_h').addClass('all_clients');
		
				$('.show_all_clients').find('.bluelink').removeClass('bluelink').addClass('graylink');
		$('.show_all_clients').find('.graylink img').eq(0).attr('src', '/i/linkgreybg_l.gif');
		$('.show_all_clients').find('.graylink img').eq(1).attr('src', '/i/linkgreybg_r.gif');
		$('.show_streams').find('.graylink').removeClass('graylink').addClass('bluelink');
		$('.show_streams').find('.bluelink img').eq(0).attr('src', '/i/linkbluebg_l.gif');
		$('.show_streams').find('.bluelink img').eq(1).attr('src', '/i/linkbluebg_r.gif');

		//$(this).parent().find('.show_streams').css({'display':'inline'});
		//$(this).css({'display':'none'});
	})
	$('.show_streams').click(function(){
		$('.all_clients').removeClass('all_clients').addClass('all_clients_h');
		$('.show_streams').find('.bluelink').removeClass('bluelink').addClass('graylink');
		$('.show_streams').find('.graylink img').eq(0).attr('src', '/i/linkgreybg_l.gif');
		$('.show_streams').find('.graylink img').eq(1).attr('src', '/i/linkgreybg_r.gif');
		$('.show_all_clients').find('.graylink').removeClass('graylink').addClass('bluelink');
		$('.show_all_clients').find('.bluelink img').eq(0).attr('src', '/i/linkbluebg_l.gif');
		$('.show_all_clients').find('.bluelink img').eq(1).attr('src', '/i/linkbluebg_r.gif');
		//$(this).parent().find('.show_all_clients').css({'display':'inline'});
		//$(this).css({'display':'none'});
	})
})


