var x_$=new Array();
var ie=document.all&&(!window.opera);
function $x(id){
	if (!x_$[id]){
		x_$[id]=document.getElementById(id);
	}
	return x_$[id];
}

function OkOver(obj){
	obj.style.backgroundPosition="-32px 0px";
}

function OkOut(obj){
	obj.style.backgroundPosition="0px 0px";
}

function Focus(obj,obj2){
	obj2.style.display='none';
	obj.focus();
}

function Blur(obj,obj2){
	if (obj.value==''){
		obj2.style.display='';
	}
}
	
function Focus1(){
	Focus($x('s_i1'),$x('s_d2'));
}

function Blur1(){
	Blur($x('s_i1'),$x('s_d2'));
}

function Focus2(){
	Focus($x('s_i2'),$x('s_d1'));
}

function Blur2(){
	Blur($x('s_i2'),$x('s_d1'));
}

function Focus4(){
	Focus($x('s_i4'),$x('s_d4'));
}

function Blur4(){
	Blur($x('s_i4'),$x('s_d4'));
}

function Load(){
	if ($x('s_i1') && $x('s_i1').value!=''){
		$x('s_d2').style.display='none';
	}
	if ($x('s_i2') && $x('s_i2').value!=''){
		$x('s_d1').style.display='none';
	}
	if ($x('s_i4') && $x('s_i4').value!=''){
		$x('s_d4').style.display='none';
	}
}
function HomePage(el){
	el.style.behavior='url(#default#homepage)';
	el.setHomePage('http://szuk.ru');
}
function Submit(){
	$x('frm1').submit();
	
}

function SetOpacity(id,op){
	if (!ie){
		$x(id).style['opacity']=op;
	}
	else{
		$x(id).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+(op*100)+')';
	}
}

function OpTmr(id,op,n){
	if (op<0){
		$x(id).style.display='none';
		clearTimeout(tmr[n]);
	}
	else{
		op-=0.05;
		SetOpacity(id,op);
		clearTimeout(tmr[n]);
		tmr[n]=setTimeout('OpTmr(\''+id+'\','+op+','+n+')',20);
	}
}
var tmr=new Array();
tmr[1]=0;
tmr[2]=0;
tmr[3]=0;
tmr[4]=0;

function ShowHint(id,tmp){
	clearTimeout(tmr[tmp]);
	$x(id).style.display='';
	SetOpacity(id,0.8);
}

function HideHintEx(id,tmp){
	tmr[tmp]=HideHint(id,tmp);	
}


function MakeHide(id,n){
	OpTmr(id,0.8,n)
}
function HideHint(id,n){
	return setTimeout('MakeHide(\''+id+'\','+n+')',100);
}

function HideHint1(){
	tmr[1]=HideHint('hint1',1);	
}
function ShowHint1(){
	ShowHint('hint1',tmr[1]);	
}
function HideHint2(){
	tmr[2]=HideHint('hint2',2);	
}
function ShowHint2(){
	ShowHint('hint2',tmr[2]);	
}
function HideHint3(){
	tmr[1]=HideHint('hint3',3);	
}
function ShowHint3(){
	ShowHint('hint3',tmr[3]);	
}
function HideHint4(){
	tmr[4]=HideHint('hint4',4);	
}
function ShowHint4(){
	ShowHint('hint4',tmr[4]);	
}
function HideHint5(){
	tmr[5]=HideHint('hint5',5);	
}
function ShowHint5(){
	ShowHint('hint5',tmr[5]);	
}

function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src;
	
		if (element.tagName=='IMG') 
		{
			if (/\.png$/.test(element.src)) 
			{
			    //if ( element.id ) {
			        imagePath   = element.src;
			        
			        /// Deletes all after images verb and inserting x.gif
			        if ( imagePath && imagePath.indexOf( "/images/" ) >= 0 ) {
			            imagePath   = imagePath.substring( 0, imagePath.indexOf( "/images/" ) + 8 ) + "x.gif";
			            src         = element.src;
				        element.src = imagePath; 
			        }
			    /*} else {
				    src         = element.src;
				    element.src = "images/x.gif"; 
				}*/
			}
		}
		else 
		{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src)
			{
				src = src[1]; 
				element.runtimeStyle.backgroundImage="none"; 
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
	}
}



function clearInnerXmlLimits(x) {
	var lastValue = "";
	var curValue = x;

    while ( curValue != lastValue ) {
        lastValue = curValue;
    	curValue = curValue.replace( "&lt;", "<" );	
	    curValue = curValue.replace( "&gt;", ">" );
	    curValue = curValue.replace( "&amp;", "&" );
    }
	
    return curValue;
}

$(document).ready( function() {
        /// Getting menu items and checking Current path
        var i          = 0;
        var items      = $("#menu > table > tbody > tr > th");
        var totalItems = items.length;
        var currentUrl = window.location.href;
        
        for( i = 0; i < totalItems; i++ ) {
            currentItem = items.eq( i );
            itemPath    = currentItem.attr( "class" );
            
            if ( currentUrl.indexOf( itemPath ) > 0 ) {
                currentItem.find( "> a" ).addClass( "selected" );
            }
        }
    } 
);

function getPos(el) {

            var iPosX=0;

            var iPosY=0;

            while (el!=null) {

                iPosX+=el.offsetLeft;

                iPosY+=el.offsetTop;

                el=el.offsetParent;

            }

            return {x:iPosX,y:iPosY};

        }


        var hintCounter=0;

        function addHint(obj,text) {            

            if (!obj.hintDiv) {

                var div=document.createElement('div');

                div.className='hint';

                div.style['position']='absolute';

                div.style['left']=getPos(obj).x+obj.offsetWidth+'px';

                div.style['top']=getPos(obj).y+'px';

                div.id='_hint'+hintCounter++;

                div.innerHTML='<div class="t"></div><div class="c">'+text+'</div><div class="b"></div></div>';

                document.body.appendChild(div);

                obj.hintDiv=div;

            }

            if (obj.hintDiv.timer)

                clearTimeout(obj.hintDiv.timer);

            obj.hintDiv.style.display='';

            SetOpacity(obj.hintDiv.id,0.8);

        }

        

        function removeHintTmr(id,op)

        {

            obj=document.getElementById(id);

            if (op<0) {

                obj.style.display='none';

                clearTimeout(obj.timer);

            }

            else {

                op-=0.05;

                SetOpacity(id,op);

                clearTimeout(obj.timer);

                obj.timer=setTimeout('removeHintTmr(\''+id+'\','+op+')',20);

            }

        }

        

        function removeHint(obj) {

            obj.timer=setTimeout('removeHintTmr(\''+obj.hintDiv.id+'\',0.8)',100);

        }