IE = navigator.appName=="Microsoft Internet Explorer";
NS = navigator.appName=="Netscape";
bVer = parseInt(navigator.appVersion);
var newWin=null;

function PopUp(loc_ie, name, width, height) {
	if (window.NewWindow == null || window.NewWindow.closed)
	{
		var _params = "width="+width+",height="+height+",resizable=no,status=no,scrollbars=0";
		loc_ns = loc_ie;
		if (bVer >= 4) {
				 _left = ( (screen.width-width) >>1 );
				 _top = ( (screen.height-height) >>1 );
		} else {
				 _left = ( (800-width) >>1 );
				 _top = ( (600-height) >>1 );
		}
		if (IE) _params += ",top=" + _top + ",left=" + _left;
		else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;
		else _params += ",screenX=" + _left + ",screenY=" + _top;
		newWin = window.open(loc_ie, name, _params);
		newWin.document.open();
		newWin.document.write('<html><head><title>Ford &mdash; &laquo;Уралавтоимпорт&raquo;</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><img src='+loc_ie+' height="'+height+'" width="'+width+'" onClick="parent.self.close(); return false" style="cursor:pointer" title="Закрыть окно" alt="Фотогалерея Ford"></body></html>');
		newWin.document.close();
		if ( newWin!=null )
				newWin.focus();
	}
	else
	{
		window.NewWindow.location.href = loc_ie;			
		window.NewWindow.focus();
	}
}

function cmnSwitch_class( eOn, sClass_name, sInstead ){
	if( cmnMatch_class( eOn, sClass_name ) ){
		cmnSet_class( eOn, sInstead, sClass_name );
	}else{
		cmnSet_class( eOn, sClass_name, sInstead );
	}
}

function cmnRemove_class( eOn, sClass_name ){
	cmnSet_class( eOn, "", sClass_name );
}

function cmnSet_class( eOn, sClass_name, sInstead ){
	if( eOn ){
		sClass_name = ( sClass_name.length ) ? sClass_name.replace( /(^\s+|\s+$)/, "" ) : "";
		if( eOn.className.length ){
			var sOld = sClass_name;
			if( sInstead && sInstead.length ){
				sInstead = sInstead.replace( /\s+(\S)/g, "|$1" );
				if( sOld ){
					sOld += "|";
				}
				sOld += sInstead;
			}
			eOn.className = eOn.className.replace( new RegExp("(^|\\s+)(" + sOld +")($|\\s+)", "g"), "$1" );
		}
		eOn.className += ( eOn.className.length && sClass_name ? " " : "" ) + sClass_name;
	}
}

function cmnMatch_class( eOn, sClass_name ){
	return ( sClass_name && eOn.className && eOn.className.length && eOn.className.match( new RegExp("(^|\\s+)(" + sClass_name +")($|\\s+)") ) );
}
