function ajaxReq( reg )
{
	doLoad( '', '/ajax/' + reg + '/' );
}



function subClick( id )
{
	$( '#lMenu .item1' ).css( {background:'url( /DESIGN/SITE/images/line.gif ) repeat-x 0px top'} );
	subNoback( 0 );
	$( '#lMenu .sub_' ).hide();
	$( '#lMenu .item1_' ).show();
	$( '#lItem'+id ).hide();
	$( '#lItem_'+id ).show();
	subNoback( id+1 );
}

function subNoback( id )
{
	if ( $( '#lItem'+id ).length )
		$( '#lItem'+id ).css( {background:'none'} );
}



function showWindow( id )
{
	getObj( id ).style.display = 'block';
}

function showWindow1( id )
{
	getObj( id ).style.display = 'block';
	window.scrollTo(0, 0);
}

function hideWindow( id, id2, id3 )
{
	getObj( id ).style.display = 'none';
	if( id2 )
	{
		var c = document.forms[id2].elements.length;
		for( var i=0; i<c; i++ )
			document.forms[id2].elements[i].value = '';
	}
	
	if( id3 )
		$( "#" + id3 ).html( '' );
}



function showPassFields( obj )
{
	if( obj.checked )
	{
		$( '#npass1t' ).removeClass( 'titleBlock' );
		$( '#npass2t' ).removeClass( 'titleBlock' );
		$( '#npass1' ).removeClass( 'fieldBlock' );
		$( '#npass2' ).removeClass( 'fieldBlock' );
		getObj( 'npass1' ).disabled = getObj( 'npass2' ).disabled = false;
	}
	else
	{
		$( '#npass1t' ).addClass( 'titleBlock' );
		$( '#npass2t' ).addClass( 'titleBlock' );
		$( '#npass1' ).addClass( 'fieldBlock' );
		$( '#npass2' ).addClass( 'fieldBlock' );
		getObj( 'npass1' ).disabled = getObj( 'npass2' ).disabled = true;
		getObj( 'npass1' ).value = getObj( 'npass2' ).value = '';
	}
}




/////////////////
function mousePageXY(e)
{
	var x = 0, y = 0;
	
	if (!e) e = window.event;
	
	if (e.pageX || e.pageY) {
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
	}
	
	return {"x":x, "y":y};
}

function showToolTip( e )
{
	if( document.all )
		e = event;
	
	var obj = getObj( 'message' );
	obj.style.display = 'block';
	
	obj.style.left = ( mousePageXY(e).x + 20 ) + 'px';
	obj.style.top = ( mousePageXY(e).y ) + 'px';
}

function hideToolTip()
{
	getObj( 'message' ).style.display = 'none';
}
/////////////////



function gotoLoc( url, url2, obj )
{
	var v = 0;
	if( $( obj ).attr( 'type' ) == 'checkbox' )
	{
		if( obj.checked )
			v = 1;
	}
	else
	{
		if( obj.value )
			v = obj.value;
	}
	
	if( !v && v != 0 )
		v = '';
	
	window.document.location.href = url + v + url2;
}





function addB( id, obj, e, c, type )
{
	if( ( e.keyCode > 47 && e.keyCode < 58 ) || e.keyCode == 8 || ( e.keyCode > 95 && e.keyCode < 106 ) )
	{
		var count = parseInt( obj.value );
		if( count < 1 || !obj.value )
			count = 0;
		/*
		else
		{
			if( count > c )
				obj.value = count = c;
		}
		*/
		
		//alert(type);
		ajaxReq( 'addB/' + parseInt( id ) + '/' + count + '/' + type );
	}
}

function delB( id )
{
	ajaxReq( 'delB/' + parseInt( id ) );
}

function resizeB()
{
	ajaxReq( 'resizeB' );
}





function vPlus( id, user )
{
	if (user===1){
		return false;
	}else{
		var v = parseInt( getObj( 'input' + id ).value );
		if( !v )
			v = 0;
		
		if( v + 1 < 10000 )
		{
			getObj( 'input' + id ).value = v + 1;
			ajaxReq( 'addB/' + parseInt( id ) + '/' + ( v + 1 ) );
		}
	}
}

function vMinus( id, user )
{
	if (user===1){
		return false;
	}else{
		var v = parseInt( getObj( 'input' + id ).value );
		if( !v )
			v = 0;
	
		if( v -1 > -1 )
		{
			getObj( 'input' + id ).value = v - 1;
			ajaxReq( 'addB/' + parseInt( id ) + '/' + ( v - 1 ) );
		}
	}
}




function slideTab()
{
	if( $( '#basketTab' ).css( 'right' ) == '-150px' )
	{
		$( '#tab' ).css({ 'background-image':'url( /DESIGN/SITE/images/basket1.png )' });
		$( '#basketTab' ).animate( { 'right':'+=150px' }, 'slow' );
		
		test = 1;
	}
	else
	{
		$( '#tab' ).css({ 'background-image':'url( /DESIGN/SITE/images/basket.png )' });
		$( '#basketTab' ).animate( { 'right':'-=150px' }, 'slow' );
		test = 0;
	}
	
	ajaxReq( 'timer' );
}

function slideTab_()
{
	if( $( '#basketTab' ).css( 'right' ) == '-150px' && test == 0 )
	{
		$( '#tab' ).css({ 'background-image':'url( /DESIGN/SITE/images/basket1.png )' });
		$( '#basketTab' ).animate( { 'right':'+=150px' }, 'slow' );
	}
	
	test = 1;
	ajaxReq( 'timer' );
}




function onBlurField()
{
	var tmp = true;
	if( document.forms['fBasket'].fName.value == '' )
		tmp = false;
		
	if( document.forms['fBasket'].fMail.value == '' )
		tmp = false;
		
	if( document.forms['fBasket'].fPhone_.value == '' )
		tmp = false;
	
	if( document.forms['fBasket'].fReg.checked )
	{
		if( document.forms['fBasket'].nPass1.value == '' )
			tmp = false;
			
		if( document.forms['fBasket'].nPass2.value == '' )
			tmp = false;
	}
	
	if( tmp )
	{
		getObj( 'bBtn_' ).style.display = 'none';
		getObj( 'bBtn' ).style.display = 'block';
	}
	else
	{
		getObj( 'bBtn' ).style.display = 'none';
		getObj( 'bBtn_' ).style.display = 'block';
	}
}

function mousePageXY(e)
{
	var x = 0, y = 0;
	
	if (!e) e = window.event;
	
		x = e.clientX;
		y = e.clientY;
	
	return {"x":x, "y":y};
}

function showToolTip(e){
	if(document.all)e = event;
	
	var obj = document.getElementById('msg');
	obj.style.display = 'block';
	
	obj.style.left = (mousePageXY(e).x - 205) + 'px';
	obj.style.top = (mousePageXY(e).y + 30) + 'px';		
	
}

function hideToolTip()
{
	document.getElementById('msg').style.display = 'none';
}
/*
$(function(){
	link = $('#clustrmaps-widget').children('a');
	l = link.attr('href');
	alert(l);
	//link.attr('rel','nofollow');
});*/
