jQuery.noConflict();

function IEPngFix(pngimg, width, height, id)
{
	var code = '<img src="img/emp.gif" width="' + width + '" height="' + height + '" border="0" style="background:url('+pngimg+') no-repeat 0px 0px;" id="'+id+'"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="img/emp.gif" width="' + width + '" height="' + height + '" border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=scale );"  id="'+id+'"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}



function showVideo(src){
jQuery('#frame').attr("src",src);
cont=jQuery('#container').get(0);
cont.style.top=document.body.scrollTop+200;
cont.style.left=document.body.clientWidth/2-320;
back=jQuery('#back_roll').get(0);
back.style.width=document.body.scrollWidth;
back.style.height=document.body.scrollHeight;
back.style.left=0;
back.style.top=0;
back.style.display='block';
cont.style.display='block';

}
function hideVideo(){
jQuery('#frame').attr("src","");
back=jQuery('#back_roll').get(0);
cont=jQuery('#container').get(0);
back.style.display='none';
cont.style.display='none';
}

function CreateBookmarkLink() {
  if (window.sidebar) { // Mozilla Firefox Bookmark
    window.sidebar.addPanel(location.href, document.title,"");
    return false;
  } else if( window.external ) { // IE Favorite
		window.external.AddFavorite(location.href, document.title)
    return false;
    }
  else if(window.opera && window.print) { // Opera Hotlist
  return true;
	}
}

function absPosition(obj) {
      var x = y = 0;
      while(obj) {
            x += obj.offsetLeft;
            y += obj.offsetTop;
            obj = obj.offsetParent;
      }
      return {x:x, y:y};
}

function showloader(){
pic=document.getElementById("slide_pic");
	posX=absPosition(pic).x;
	posY=absPosition(pic).y;
	oLoader=document.getElementById("loader");
	oLoader.style.left=posX+500;
	oLoader.style.top=posY+pic.offsetHeight/2;
	oLoader.style.display='block';
}
function update_slide(originalRequest){
var q = originalRequest.responseText.evalJSON(true);//eval('(' + originalRequest.responseText + ')');
	jQuery("#slide_pic").attr("src","images/case/"+q.img.caseID+"_"+q.img.num+"."+q.img.name+"."+q.img.ext);
	jQuery("#slide_pic").attr("height",q.img.height);
	
	jQuery("#curr_slide").get(0).innerHTML=q.img.ID;
	if(q.next) jQuery(".b_slide_next").show();
	else jQuery(".b_slide_next").hide();
	if(q.prev) jQuery(".b_slide_prev").show();
	else jQuery(".b_slide_prev").hide();
	colLink=jQuery(".pslide").get();
	jQuery(".pslide").attr("class","page pslide");
	for(i=0;i<colLink.length;i++){
		num=colLink[i].getAttribute("num");
		if(num==q.img.ID) colLink[i].className="apage pslide";
	}
	hideloader();
}
function hideloader(){
	document.getElementById("slide_pic").onload=function(){
			document.getElementById("loader").style.display='none';
	}
}

//эмуляция тега файл
var W3CDOM = (document.createElement && document.getElementsByTagName);
function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	var fakeText=document.createElement('input');
	
	fakeText.id="fakeText";
	if(document.getElementById("fileinputs").getAttribute("error")=="1"){
		fakeText.value="ФОРМАТА РЕЗЮМЕ - DOC ИЛИ PDF";
		fakeText.className = 'filt_inp2 expand error';
	}
	else{ 
		fakeText.value="ПРИКРЕПИТЕ ВАШЕ РЕЗЮМЕ";
		fakeText.className = 'filt_inp2 expand';
	}
	fakeFileUpload.appendChild(fakeText);
	var image = document.createElement('img');
	image.src='img/b_brows.gif';
	image.id='b_brows';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = document.getElementById('fakeText');
			x[i].onchange = x[i].onmouseout = function () {
				this.relatedElement.value = this.value;
				destroyEClass(this.relatedElement);
			}
		x[i].onmouseover=function(){jQuery('#b_brows').attr('src', 'img/b_brows1.gif');};
		x[i].onmouseout=function(){jQuery('#b_brows').attr('src', 'img/b_brows.gif');};
	}
}
//

var monthArray = ['','ЯНВАРЬ','ФЕВРАЛЬ','МАРТ','АПРЕЛЬ','МАЙ','ИЮНЬ','ИЮЛЬ','АВГУСТ','СЕНТЯБРЬ','ОКТЯБРЬ','НОЯБРЬ','ДЕКАБРЬ'];
function selectFYear(originalRequest){
selObj=jQuery("#selectMonth").get(0);
len=selObj.childNodes.length;
for(i=1;i<len;i++)
{
	oChild=selObj.childNodes[1];
	selObj.removeChild(oChild);
}

var q = eval('(' + originalRequest.responseText + ')');
	for(i=0;i<q.length;i++){
		var oOption = document.createElement("option");
		text=monthArray[q[i]];
		oOption.appendChild(document.createTextNode(text));
		oOption.setAttribute("value", q[i]);
		selObj.appendChild(oOption);
	}
}

jQuery(document).ready(function(){
//	jQuery('body').pngFix( );
	if(jQuery("#loader").get(0)!=null){
		showloader();
		hideloader();
	}
	if(jQuery("input.file").get(0)!=null) initFileUploads();
	jQuery('#b_allnews').hover(
		function(){ jQuery(this).attr('src', 'img/b_allnews1.gif'); },
		function(){ jQuery(this).attr('src', 'img/b_allnews.gif'); }
	);

	
	jQuery('#b_alllist').hover(
		function(){ jQuery(this).attr('src', 'img/b_alllist1.gif'); },
		function(){ jQuery(this).attr('src', 'img/b_alllist.gif'); }
	);
	jQuery('.ico_home').hover(
		function(){ jQuery(this).attr('src', 'img/ico_home1.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/ico_home.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.ico_mail').hover(
		function(){ jQuery(this).attr('src', 'img/ico_mail1.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/ico_mail.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.ico_star').hover(
		function(){ jQuery(this).attr('src', 'img/ico_star1.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/ico_star.png'); jQuery(this).pngFix( ); }
	);

	jQuery('.m1').hover(
		function(){ jQuery(this).attr('src', 'img/m11.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m1.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m1_').hover(
		function(){ jQuery(this).attr('src', 'img/m11.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m12.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m2').hover(
		function(){ jQuery(this).attr('src', 'img/m21.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m2.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m3').hover(
		function(){ jQuery(this).attr('src', 'img/m31.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m3.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m3_').hover(
		function(){ jQuery(this).attr('src', 'img/m31.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m32.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m4').hover(
		function(){ jQuery(this).attr('src', 'img/m41.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m4.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m4_').hover(
		function(){ jQuery(this).attr('src', 'img/m41.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m42.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.m5').hover(
		function(){ jQuery(this).attr('src', 'img/m51.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/m5.png'); jQuery(this).pngFix( ); }
	);


	jQuery('.sm1').hover(
		function(){ jQuery(this).attr('src', 'img/sm11.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/sm1.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.sm2').hover(
		function(){ jQuery(this).attr('src', 'img/sm21.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/sm2.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.sm3').hover(
		function(){ jQuery(this).attr('src', 'img/sm31.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/sm3.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.sm3_').hover(
		function(){ jQuery(this).attr('src', 'img/sm31.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/sm32.png'); jQuery(this).pngFix( ); }
	);
	jQuery('.sm4').hover(
		function(){ jQuery(this).attr('src', 'img/sm41.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/sm4.png'); jQuery(this).pngFix( ); }
	);


	jQuery('.sm51').hover(
		function(){ jQuery(this).attr('src', 'img/smsm511.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/smsm51.png'); jQuery(this).pngFix( ); }
	);

	jQuery('.sm31').hover(
		function(){ jQuery(this).attr('src', 'img/smsm31.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/smsm32.png'); jQuery(this).pngFix( ); }
	);

	jQuery('.sm52').hover(
		function(){ jQuery(this).attr('src', 'img/smsm521.png'); jQuery(this).pngFix( ); },
		function(){ jQuery(this).attr('src', 'img/smsm52.png'); jQuery(this).pngFix( ); }
	);



	jQuery('#b_filt').hover(
		function(){ jQuery(this).attr('src', 'img/arrow_filt1.gif');},
		function(){ jQuery(this).attr('src', 'img/arrow_filt.gif');}
	);

	jQuery('#b2_filt').hover(
		function(){ jQuery(this).attr('src', 'img/arrow2_filt1.gif');},
		function(){ jQuery(this).attr('src', 'img/arrow2_filt.gif');}
	);

	jQuery('.b_openprev').hover(
		function(){ jQuery(this).attr('src', 'img/b_more1.gif'); },
		function(){ jQuery(this).attr('src', 'img/b_more.gif'); }
	);
	jQuery('.b_closeprev').hover(
		function(){ jQuery(this).attr('src', 'img/b_close1.gif'); },
		function(){ jQuery(this).attr('src', 'img/b_close.gif'); }
	);
	jQuery('#b_brows').hover(
		function(){ jQuery(this).attr('src', 'img/b_brows1.gif');},
		function(){ jQuery(this).attr('src', 'img/b_brows.gif');}
	);
	jQuery('#b_send').hover(
		function(){ jQuery(this).attr('src', 'img/b_send1.gif');},
		function(){ jQuery(this).attr('src', 'img/b_send.gif');}
	);


	jQuery('#b_back').hover(
		function(){ jQuery(this).attr('src', 'img/b1_back1.gif');},
		function(){ jQuery(this).attr('src', 'img/b1_back.gif');}
	);
	jQuery('#b2_back').hover(
		function(){ jQuery(this).attr('src', 'img/b2_back1.gif');},
		function(){ jQuery(this).attr('src', 'img/b2_back.gif');}
	);


	jQuery('.b_prev').hover(
		function(){ jQuery(this).attr('src', 'img/b_prev1.gif');},
		function(){ jQuery(this).attr('src', 'img/b_prev.gif');}
	);
	jQuery('.b_next').hover(
		function(){ jQuery(this).attr('src', 'img/b_next1.gif');},
		function(){ jQuery(this).attr('src', 'img/b_next.gif');}
	);




	jQuery('.b_openprev').click(
		function()
		{
			num = jQuery(this).attr('num');
			jQuery('#tab'+num).hide();
			jQuery('#t'+num).show();
			jQuery('#prev'+num).show('middle');
			return false;
		}
	);
	jQuery('.b_closeprev').click(
		function()
		{
			num = jQuery(this).attr('num');
			jQuery('#tab'+num).show();
			jQuery('#t'+num).hide();
			jQuery('#prev'+num).hide('middle');
			return false;
		}
	);

	jQuery(".popup_link").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		opacity: 1,
		fixPNG: false,
		showBody: " - ",
		top: 10,
		left: 5
	});
});