function add_to_basket( index, flag )
{
	var xmlhttp1;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp1= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp1.open("GET", "basket.php?act=add&ind="+index, false); // синхронный запрос для примера
	xmlhttp1.send( null );
	
	if( ! xmlhttp1.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp1;
		
		var xmlhttp1;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp1= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp1= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp1.open( "GET", "basket.php?act=add&ind="+index, false );
		xmlhttp1.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp1.send( null );
		
		if( xmlhttp1.status == 304 )
		{
			xmlhttp1= cached;
		}
	}
	
	if( xmlhttp1.readyState == 4 && xmlhttp1.status == 200 )
	{
		print_head_basket();
	}

	if( flag == 'goto' )
	{
		location.replace( "basket.php" );
	}
}

function del_from_basket( index, count )
{
	var xmlhttp2;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp2= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp2.open("GET", "basket.php?act=del&ind="+index+"&count="+count, false); // синхронный запрос для примера
	xmlhttp2.send( null );
	
	if( ! xmlhttp2.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp2;
		
		var xmlhttp2;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp2= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp2= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp2.open( "GET", "basket.php?act=del&ind="+index+"&count="+count, false );
		xmlhttp2.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp2.send( null );
		
		if( xmlhttp2.status == 304 )
		{
			xmlhttp2= cached;
		}
	}
	
	if( xmlhttp2.readyState == 4 && xmlhttp2.status == 200 )
	{
		print_head_basket();
	}
}

function print_basket_count( index )
{
	var xmlhttp3;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp3= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp3= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp3.open("GET", "basket.php?act=count&ind="+index, false); // синхронный запрос для примера
	xmlhttp3.send( null );
	
	if( ! xmlhttp3.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp3;
		
		var xmlhttp3;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp3= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp3= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp3.open( "GET", "basket.php?act=count&ind="+index, false );
		xmlhttp3.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp3.send( null );
		
		if( xmlhttp3.status == 304 )
		{
			xmlhttp3= cached;
		}
	}
	
	if( xmlhttp3.readyState == 4 && xmlhttp3.status == 200 )
	{
		document.getElementById( "this_cat_count_" + index ).innerHTML= xmlhttp3.responseText;
	}
}

function add_to_sravnenie( index )
{
	var xmlhttp4;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp4= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp4= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp4.open("GET", "comparison.php?act=add&ind="+index, false); // синхронный запрос для примера
	xmlhttp4.send( null );
	
	if( ! xmlhttp4.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp4;
		
		var xmlhttp4;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp4= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp4= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp4.open( "GET", "comparison.php?act=add&ind="+index, false );
		xmlhttp4.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp4.send( null );
		
		if( xmlhttp4.status == 304 )
		{
			xmlhttp4= cached;
		}
	}
	
	document.getElementById( "img_sravnenie_"+index ).src= "images/add_to_sravnenie_3.png";
	
	if( xmlhttp4.responseText == "sravn_true" )
	{
		location.replace( "comparison.php" );
	}
}


function classname( id, classname )
{
	document.getElementById( id ).className= classname;
	document.getElementById( 'refresher' ).innerHTML= '<br /><center><img align="bottom" src="images/loading19.gif" alt="" /> обновление каталога ...</center>';
}


function act_to( ind, type, val1, val2, num, brand, sort )
{
	var xmlhttp5;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp5= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp5= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp5.open("GET", "catalog_items.php?ind="+ind+"&type="+type+"&val1="+val1+"&val2="+val2+"&num="+num+"&brand="+brand+"&sort="+sort, false);
	xmlhttp5.send( null );
	
	if( ! xmlhttp5.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp5;
		
		var xmlhttp5;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp5= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp5= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp5.open( "GET", "catalog_items.php?ind="+ind+"&type="+type+"&val1="+val1+"&val2="+val2+"&num="+num+"&brand="+brand+"&sort="+sort, false );
		xmlhttp5.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp5.send( null );
		
		if( xmlhttp5.status == 304 )
		{
			xmlhttp5= cached;
		}
	}
	
	if( xmlhttp5.readyState == 4 && xmlhttp5.status == 200 )
	{
		document.getElementById( "catalog_items" ).innerHTML= xmlhttp5.responseText;
		
		//tt_Init();

		var $w2 = jQuery.noConflict();

		$w2(".zimage").mouseover(function(){
			var src = $w2(this).attr('src');
			Tip('<img border=0 src=' + src + '>', BGCOLOR, '#ffffff', FONTCOLOR, '#333333', BORDERCOLOR, 'Silver', WIDTH, '100%', FADEIN, 500, FADEOUT, 500);
		});
	}
}

function print_head_basket(  )
{
	var xmlhttp6;
	
	if( window.XMLHttpRequest )
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp6= new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp6= new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	
	xmlhttp6.open("GET", "basket.php?act=print_head_basket", false); // синхронный запрос для примера
	xmlhttp6.send( null );
	
	if( ! xmlhttp6.getResponseHeader( "Date" ) ){ // 1
		var cached= xmlhttp6;
		
		var xmlhttp6;
		
		if( window.XMLHttpRequest )
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp6= new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp6= new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		
		var ifModifiedSince= cached.getResponseHeader("Last-Modified");
		
		ifModifiedSince= (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970
		xmlhttp6.open( "GET", "basket.php?act=print_head_basket", false );
		xmlhttp6.setRequestHeader( "If-Modified-Since", ifModifiedSince );
		xmlhttp6.send( null );
		
		if( xmlhttp6.status == 304 )
		{
			xmlhttp6= cached;
		}
	}
	
	if( xmlhttp6.readyState == 4 && xmlhttp6.status == 200 )
	{
		document.getElementById( "bl_basket" ).innerHTML= xmlhttp6.responseText;
	}
}
