function donothing() {
}

function reloadSI() {
	document.getElementById('si').src='si.php?id='+Math.random();	
}

function goToMain () {
	window.location.href=siteURL;
}

function goToMap () {
	window.location.href=siteURL+'sitemap.html';
}

function goToSearch () {
	window.location.href=siteURL+'search.html';
}

function goToCarsOrders () {
	window.location.href=siteURL+'auto-salvage-kits/index.html';
}

// Change table style

function HighLight ( tr, oldclass, newclass, check ) {

	currentclass = tr.className;
 
	if ( currentclass != 'bg5' && newclass != 'bg5' ) {
 		tr.className = newclass;
	}
	else {
		
		if ( currentclass == 'bg5' && newclass == 'bg5' ) { // unmark
			tr.className = oldclass;
			
			if ( check && oldclass != 'bg3' )
				document.getElementById( check ).checked = false;			
		
		}
		else if ( currentclass != 'bg5' && newclass == 'bg5' ) { // mark
			tr.className = newclass;
			
			if ( check && oldclass != 'bg3' )
				document.getElementById( check ).checked = true;
		
		}
				
	} 
 
}

// Set selected

function setSelectedSelect ( id, value, submit_id ) {
	
	if( typeof( id ) != 'object' )
		var element = document.getElementById( id );
	else var element = id;
	
	var select_cnt = element.options.length;
  selected = 0;
  
  for ( j = 0; j < select_cnt; j++ ) {
  	
  	if ( element[j].value == value )
  		selected = j;
  }
	
	element.selectedIndex = selected;
	
	// Submit
	
	if( typeof submit_id != 'undefined' )
		if( document.getElementById( submit_id ) )
			document.getElementById( submit_id ).submit();

}

// Set value

function setValue ( id, value, submit_id ) {
	
	if( typeof( id ) != 'object' )
		var element = document.getElementById( id );
	else var element = id;
	
	document.getElementById( id ).value = value;
	
	// Submit
	
	if( typeof submit_id != 'undefined' )
		if( document.getElementById( submit_id ) )
			document.getElementById( submit_id ).submit();

}

// Convert url

function convertMM( text ) {
	
	text = text.replace( ".", "_" );
	text = text.replace( " ", "_" );
	text = text.replace( "(", "_" );
	text = text.replace( ")", "_" );
	text = text.replace( "\"", "_" );
	text = text.replace( "\\", "_" );
	text = text.replace( "/", "_" );
	text = text.replace( "-", "_" );
	
	return ( text );
	
}

function getSelectedText( elementId ) {
    
	var elt = document.getElementById( elementId );
	
	if( elt.selectedIndex == -1 )
	    return null;
	
	return elt.options[ elt.selectedIndex ].text;

}

// Open catalog from search form

function openCatalogFromSearchForm() {
	
	// Get mark name
	
	var mark = convertMM( getSelectedText( 'auto_brand' ) );
	
	// Get model name
	
	var model = convertMM( getSelectedText( 'auto_model' ) );
	
	// Get part type
	
	var part_type = document.getElementById( 'part_type' ).value;
	
	// Form url
	
	if( mark && model ) {
	
		var url = 'search/'+mark+'-'+model;
		
		if( part_type )
			url += '-'+part_type;
		
		url += '.html';
		
	}
	else {
		
		var url = 'catalog.html';
		
	}
	
	// Go to catalog
	
	window.location.href= url;
	
}
